π Breaking Changes
π AST Builder
AST Builder is now ready to be used!
GlueSQL AST builder provides iterator chaining experience to manipulate data which is similar to array chaining methods or DataFrame syntax.
For someone who is already familiar with SQL, then there would be almost no extra learning cost to use GlueSQL AST builder.
AST builder accepts various sets of params - not only the expression built by its own expr builder, but also it even accepts raw SQL text and prebuilt ASTs.
e.g.
table("Item")
.select()
.join("Category")
.on(col("Category.id").eq("Item.category_id"))
.group_by("Item.category_id")
.having("SUM(Item.price) > 80")
.project("Category.name AS category")
.project("SUM(Item.price) AS sum_price")
.execute(glue)
.await;
| category | sum_price
|------------|-------------|
| Meat | 90 |
| Drink | 85 |
Usage code examples
SELECT queries
INSERT queries
UPDATE queries
DELETE queries
Related PRs (features)
- Implement hash join support to AST builder @panarch (#916)
- [AST-Builder] Impl Case @ding-young (#910)
- [AST] Support
ArrayIndex
Expr @ding-young (#880)
- Implement AST builder execute function @panarch (#879)
- [Ast Builder] Implement join expression in select statement @seonghun-dev (#803)
- [AST] Implement to_sql func for OrderByExpr @CEOJINSUNG (#812)
- [AST Builder] Implement to_date and let format function to format date data type @ChobobDev (#858)
- [AST Builder] Implement Lower function @ChobobDev (#853)
- Implement order by ast builder @24seconds (#841)
- [AST builder] Implement To_date and To_timestamp function @ChobobDev (#838)
- [AST Builder] Implement format function @ChobobDev (#836)
- [AST builder] Implement Insert statement @kim-seo-hyun (#802)
- [AST Builder] Implement Alter table statement @ding-young (#813)
- [AST-Builder] Create Table Statement @ding-young (#784)
- [AST Builder] Implement EXISTS Expression @CEOJINSUNG (#790)
- [AST Builder] Implement update Expression @seonghun-dev (#720)
- [AST Builder] Implement Div, Mod Function @seonghun-dev (#760)
Related PRs (improvements)
- Add AST builder integration tests of SELECT, UPDATE, INSERT and DELET⦠@panarch (#955)
- Update AST builder cast function unit test @zmrdltl (#957)
- Expose AST builder unary_op methods to public, @panarch (#956)
- Rename AST builder ExprNode::not to ExprNode::negate @sa1 (#953)
- Add missing select nodes to ExprNode::InList and QueryNode in AST builder @panarch (#934)
- Simplify ast_builder/ QueryNode codes using decl macro @panarch (#932)
- Add from ProjectNode & QueryNode for InListNode in AST builder, @panarch (#925)
- Update ast-builder function expr params to use
Into<..Node>
@panarch (#926)
- Update AST builder between & hash_executor to accept different param β¦ @panarch (#923)
- Add ExprNode::subquery, @panarch (#922)
- Add AST builder join nodes to query node conversion support @panarch (#921)
- Add setting table_alias support to AST builder table init function @panarch (#920)
- [AST Builder] Combine in_list and in_subquery into in_list @CEOJINSUNG (#808)
- [AST-Builder] change error message in test functions @ding-young (#800)
- Reformat : change ast builder function format @seonghun-dev (#796)
π Features
π New metadata tables - GLUE_TABLES
, GLUE_TABLE_COLUMNS
and GLUE_INDEXES
gluesql> SELECT * FROM GLUE_TABLES;
| TABLE_NAME |
|------------|
| Bar |
| Foo |
gluesql> SELECT * FROM GLUE_TABLE_COLUMNS;
| TABLE_NAME | COLUMN_NAME | COLUMN_ID |
|------------|-------------|-----------|
| Bar | id | 1 |
| Bar | name | 2 |
| Bar | type | 3 |
| Foo | id | 1 |
| Foo | name | 2 |
gluesql> SELECT * FROM GLUE_INDEXES;
| TABLE_NAME | INDEX_NAME | ORDER | EXPRESSION | UNIQUENESS |
|------------|----------------|-------|------------|------------|
| Foo | PRIMARY | BOTH | id | TRUE |
| Foo | Foo_id_1 | BOTH | id + 1 | FALSE |
| Foo | Foo_name_concat | BOTH | name + "_" | FALSE |
- Add support
GLUE_INDEXES
reserved table which provides all index info @devgony (#935)
- Support Dictionary(Schema) view @devgony (#869)
π§ ORDER BY enhancements
Support ORDER BY ALIAS
clause like below
SELECT column_name AS alias_name FROM Table ORDER BY alias_name DESC
- Currently, it throws
[error] value not found: alias_name
Original column_name
is still available at ORDER BY clause though SELECT clause uses alias_name
SELECT column_name AS alias_name FROM Table ORDER BY column_name DESC
Support ORDER BY COLUMN_INDEX
SELECT alpha, beta FROM Table ORDER BY 1 DESC
1
means the column_index which is first column alpha
Support ORDER BY
clause in VALUES list
gluesql> VALUES (1, 'a'), (2, 'b') ORDER BY column1 DESC;
column1 | column2
---------+---------
2 | b
1 | a
Related PRs
- Support ORDER BY
ALIAS
and COLUMN_INDEX
@devgony (#805)
- Support
ORDER BY
clause in VALUES list
@devgony (#730)
π ToSql
trait for AST which provides AST to SQL text conversion for easier debugging
e.g.
ToSql::to_sql
from the below AST returns this simple SQL text.
CREATE TABLE Foo (id INT, num INT NULL, name TEXT);
Statement::CreateTable {
if_not_exists: false,
name: "Foo".into(),
columns: vec![
ColumnDef {
name: "id".to_owned(),
data_type: DataType::Int,
options: vec![]
},
ColumnDef {
name: "num".to_owned(),
data_type: DataType::Int,
options: vec![ColumnOptionDef {
name: None,
option: ColumnOption::Null
}]
},
ColumnDef {
name: "name".to_owned(),
data_type: DataType::Text,
options: vec![]
}
],
source: None
}
.to_sql()
Related PRs
- Implement to_sql func for SetExpr, Join @CEOJINSUNG (#898)
- [AST] Implement to_sql func for Query, SetExpr, Select, SelectItem, TableWithJoins, IndexItem, TableFactor, TableAlias @CEOJINSUNG (#860)
- [AST] To_sql for CREATE TABLE, ALTER TABLE @ding-young (#807)
- [AST] to_sql for Function @ding-young (#931)
- [AST] to_sql for STATEMENTS @ding-young (#824)
- [AST] Implement to_sql for INSERT, UPDATE, DELETE @ding-young (#821)
π³ New datatype and functions
New datatype - UINT8
- [Data] add data type u8 @zmrdltl (#828)
New functions - ASCII
, CHR
, POSITION
, TO_DATE
, TO_TIMESTAMP
and FORMAT
- Implement ASCII, Chr functions @seonghun-dev (#881)
- Implement function
POSITION
@zmrdltl (#862)
- Implement str_position function under enum Value @zmrdltl (#875)
- [Function] Implement
TO_TIME
function and let FORMAT
get TIME
data type @ChobobDev (#842)
- [Function] Implement
TO_DATE
and TO_TIMESTAMP
function @ChobobDev (#833)
- [Function] Implement
FORMAT
function @ChobobDev (#818)
π CLI enhancements
Support .edit {fileName|None}
in CLI @devgony (#871)
- Open temporary editor with last SQL
$> cargo run
gluesql> .run
[error] Nothing in SQL history to run.
gluesql> SELECT 1, 'a', true
| 1 | 'a' | true |
|---|-----|------|
| 1 | a | TRUE |
gluesql> .edit
=> open Editor with last command on temporary file like /tmp/Glue_****.sql
-- modify in editor
SELECT 1, 'a', true, 2, 'b'
If you want to fix editor type, run below command on OS
# (optional)
$> export EDITOR=vi
gluesql> .run
| 1 | 'a' | true | 2 | 'b' |
|---|-----|------|---|-----|
| 1 | a | TRUE | 2 | b |
- Open editor with physical file
gluesql> .edit foo.sql
-- modify in editor
SELECT 1 AS no, 'In physical file' AS name
gluesql> .execute foo.sql
| no | name |
|----|------------------|
| 1 | In physical file |
New CLI print options
gluesql> .set tabular OFF
gluesql> .set colsep ,
gluesql> .set colwrap '
gluesql> .set heading OFF
gluesql> VALUES (1, 'a', true), (2, 'b', false)
'1','a','true'
'2','b','false'
- Support CLI options @devgony (#820)
Change default print style to markdown
Set markdown as default print style like below
gluesql> SELECT * FROM (VALUES (1, 'a', true), (2, 'b', false)) AS Sub;
| column1 | column2 | column3 |
|---------|---------|---------|
| 1 | a | TRUE |
| 2 | b | FALSE |
(pasted from gluesql directly)
- Replace crate::
comfy-table
with tabled
@devgony (#830)
π‘ Improvements
Aggregation
- Support
Expr::Case
in aggregate module @ever0de (#945)
- Update aggregate functions to support
Expr
@zmrdltl (#749)
sqlparser-rs
upgrades
- Upgrade sqlparser-rs to v0.25 @panarch (#907)
- Upgrade sqlparser-rs to v0.24, migrate Interval from Literal to Expr @panarch (#904)
- Upgrade sqlparser-rs to v0.22 @panarch (#819)
- Migrate sqlparser-rs from 0.18 to 0.19, @panarch (#817)
Tests
- [FIx] add omitted uint8 integration test @ChobobDev (#951)
- Rename showcolumns to show_columns @sa1 (#936)
- Replace plan/join.rs unit tests to use AST builder! @panarch (#929)
- Update test-suite select macros to support raw string literals for labels @panarch (#896)
- [Test Suite] add null test in function position @zmrdltl (#901)
- Update test-suite Tester trait to use Glue struct @panarch (#872)
- Add cli/ print and command modules to code coverage tests @panarch (#866)
- [Test suite] Add insert integration test @kim-seo-hyun (#826)
- [Test Suite] unify order of test arguments @zmrdltl (#816)
- [Test Suite] Change the structure of macros used & the order of arguments @zmrdltl (#804)
- Enhance the coverage of
operator.rs
@ChobobDev (#783)
- [Test Suite] rearrange
error test cases
to correct file
@zmrdltl (#794)
- [Test Suite] move
top level test files
to new tester folder
@zmrdltl (#792)
Other improvements
- Move Expr::Extract structure to Expr::Function::Extract @zmrdltl (#930)
- Feat : Apply macros in i16 data type @ChobobDev (#940)
- Bump
uuid
version to 1.2.1
@ever0de (#943)
- Provide unsupported warning for select distinct @sa1 (#942)
- Use decl macro to simplify codes in parser_sql module @sa1 (#937)
- Expose Row to Payload::Select and add Row to core::prelude @panarch (#941)
- Add firefox headless browser test to github action @panarch (#939)
- Remove Option which wraps Row in FilterContext, @panarch (#933)
- Add a new method to Row which finds value by ident, @panarch (#928)
- Add /pkg/rust/data/ to .gitignore @panarch (#927)
- Move Expr::Cast structure to Expr::Function::Cast @zmrdltl (#913)
- Grouping
GlueSQL
projects into pkg/*
per language @ever0de (#917)
- Implement macro that implements
TryBinaryOperator
, @ever0de (#915)
- Implement Key::to_be_bytes for Decimal variant @panarch (#906)
- Add Send + Sync trait bounds to gluesql::Error::Storage variant @panarch (#903)
- Enable str to string clippy options @ever0de (#900)
- Use variable instead of closure in core/ evaluate function module @ever0de (#892)
- Remove comment @ever0de (#891)
- Update coverage.yml to ignore root examples @panarch (#887)
- Update README.md; add
await
keyword. @24seconds (#889)
- Add root workspace in members @ever0de (#885)
- Auto Implement
GStore
, GStoreMut
traits @ever0de (#884)
- refactor: remove redundant TableFactor::Series.name @devgony (#878)
- Remove unused comments in core/ ast/mod.rs @panarch (#877)
- Remove Result from core/ table::get_alias return type @panarch (#876)
- refactor: Replace
ObjectName
with String
@devgony (#873)
- [Style]remove unnecessary bracket @ChobobDev (#863)
- Remove deprecated wee_alloc dependency use in gluesql-js/ @panarch (#856)
- [Docs] update README @zmrdltl (#852)
- [Data] modify uint8 to parse sql 'INT(8) UNSIGNED' format to 'UINT8' @zmrdltl (#851)
- [Data] modify int128 to parse sql int(128) format to int128 @zmrdltl (#850)
- [Data] remove data type int64 @zmrdltl (#849)
- [Data] modify int32 to parse sql int(32) format to int32 @zmrdltl (#848)
- [Data] modify int16 to parse sql int(16) format to int16 @zmrdltl (#847)
- [Data] modify int8 to parse sql int(8) format to int8 @zmrdltl (#846)
- Improvement
validate_unique
function when only PrimaryKey
exists @ever0de (#832)
- Simplify root doc comment code example @panarch (#831)
- Small improvement: add clear guide for web example module @24seconds (#797)
- Impl
TryFrom<&Value> for usize
@devgony (#795)
π Bug Fixes
- Fix test-suite tester::test to properly print expected & found labels @panarch (#949)
- fix: unmatced subquery should return Null (not error) @devgony (#948)
- Fix COUNT aggregate to return 0 not 1 if no rows found @ever0de (#946)
- Fix web/ payload data_type json serialization, @panarch (#938)
- Set default-run to root workspace Cargo.toml @panarch (#888)
- Update core/ chrono dependency version to 0.4.22, specify patch version @panarch (#840)
New Contributors
- @sa1 made their first contribution in https://github.com/gluesql/gluesql/pull/936
Full Changelog: https://github.com/gluesql/gluesql/compare/v0.12.0...v0.13.0
Source code(tar.gz)
Source code(zip)