Skip to content

Commit f2d7aea

Browse files
1NepuNep1Viktor Pentyukhov
andauthored
Expanding YQL Syntax support in sqlc engine (Refactored SELECT (Supported DISTINCT, HAVING, GROUP BY, ORDER BY, LIMIT, OFFSET, UNION), added ALTER TABLE, DO stmt) (#10)
* Added ALTER TABLE support * Added DO stmt support * Fixed DO stmt generation * Refactored SELECT logic. Supported DISTINCT, HAVING, GROUP BY, ORDER BY, LIMIT, OFFSET, UNION * Fixed style and types * Refactored DO stmt style & added some additional converts --------- Co-authored-by: Viktor Pentyukhov <nepunep@172.28.98.114-red.dhcp.yndx.net>
1 parent 14b60c5 commit f2d7aea

File tree

6 files changed

+830
-75
lines changed

6 files changed

+830
-75
lines changed

internal/engine/ydb/catalog_tests/delete_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func TestDelete(t *testing.T) {
101101
},
102102
},
103103
OnSelectStmt: &ast.SelectStmt{
104+
DistinctClause: &ast.List{},
104105
ValuesLists: &ast.List{
105106
Items: []ast.Node{
106107
&ast.List{
@@ -110,8 +111,12 @@ func TestDelete(t *testing.T) {
110111
},
111112
},
112113
},
113-
FromClause: &ast.List{},
114-
TargetList: &ast.List{},
114+
FromClause: &ast.List{},
115+
TargetList: &ast.List{},
116+
GroupClause: &ast.List{},
117+
WindowClause: &ast.List{},
118+
SortClause: &ast.List{},
119+
LockingClause: &ast.List{},
115120
},
116121
ReturningList: &ast.List{
117122
Items: []ast.Node{
@@ -145,6 +150,7 @@ func TestDelete(t *testing.T) {
145150
},
146151
},
147152
OnSelectStmt: &ast.SelectStmt{
153+
DistinctClause: &ast.List{},
148154
TargetList: &ast.List{
149155
Items: []ast.Node{
150156
&ast.ResTarget{
@@ -153,7 +159,12 @@ func TestDelete(t *testing.T) {
153159
},
154160
},
155161
},
156-
FromClause: &ast.List{},
162+
FromClause: &ast.List{},
163+
GroupClause: &ast.List{},
164+
WindowClause: &ast.List{},
165+
ValuesLists: &ast.List{},
166+
SortClause: &ast.List{},
167+
LockingClause: &ast.List{},
157168
},
158169
ReturningList: &ast.List{
159170
Items: []ast.Node{

internal/engine/ydb/catalog_tests/insert_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func TestInsert(t *testing.T) {
2828
},
2929
},
3030
SelectStmt: &ast.SelectStmt{
31+
DistinctClause: &ast.List{},
3132
ValuesLists: &ast.List{
3233
Items: []ast.Node{
3334
&ast.List{
@@ -40,6 +41,10 @@ func TestInsert(t *testing.T) {
4041
},
4142
TargetList: &ast.List{},
4243
FromClause: &ast.List{},
44+
GroupClause: &ast.List{},
45+
WindowClause: &ast.List{},
46+
SortClause: &ast.List{},
47+
LockingClause: &ast.List{},
4348
},
4449
OnConflictClause: &ast.OnConflictClause{},
4550
ReturningList: &ast.List{
@@ -68,6 +73,7 @@ func TestInsert(t *testing.T) {
6873
},
6974
},
7075
SelectStmt: &ast.SelectStmt{
76+
DistinctClause: &ast.List{},
7177
ValuesLists: &ast.List{
7278
Items: []ast.Node{
7379
&ast.List{
@@ -79,6 +85,10 @@ func TestInsert(t *testing.T) {
7985
},
8086
TargetList: &ast.List{},
8187
FromClause: &ast.List{},
88+
GroupClause: &ast.List{},
89+
WindowClause: &ast.List{},
90+
SortClause: &ast.List{},
91+
LockingClause: &ast.List{},
8292
},
8393
OnConflictClause: &ast.OnConflictClause{
8494
Action: ast.OnConflictAction_INSERT_OR_IGNORE,
@@ -106,7 +116,16 @@ func TestInsert(t *testing.T) {
106116
Stmt: &ast.InsertStmt{
107117
Relation: &ast.RangeVar{Relname: strPtr("users")},
108118
Cols: &ast.List{Items: []ast.Node{&ast.ResTarget{Name: strPtr("id")}}},
109-
SelectStmt: &ast.SelectStmt{ValuesLists: &ast.List{Items: []ast.Node{&ast.List{Items: []ast.Node{&ast.A_Const{Val: &ast.Integer{Ival: 4}}}}}}, TargetList: &ast.List{}, FromClause: &ast.List{}},
119+
SelectStmt: &ast.SelectStmt{
120+
DistinctClause: &ast.List{},
121+
ValuesLists: &ast.List{Items: []ast.Node{&ast.List{Items: []ast.Node{&ast.A_Const{Val: &ast.Integer{Ival: 4}}}}}},
122+
TargetList: &ast.List{},
123+
FromClause: &ast.List{},
124+
GroupClause: &ast.List{},
125+
WindowClause: &ast.List{},
126+
SortClause: &ast.List{},
127+
LockingClause: &ast.List{},
128+
},
110129
OnConflictClause: &ast.OnConflictClause{Action: ast.OnConflictAction_UPSERT},
111130
ReturningList: &ast.List{Items: []ast.Node{&ast.ResTarget{Val: &ast.ColumnRef{Fields: &ast.List{Items: []ast.Node{&ast.String{Str: "id"}}}}, Indirection: &ast.List{}}}},
112131
},

0 commit comments

Comments
 (0)