Skip to content

Commit

Permalink
Support create table as select with column list (#214)
Browse files Browse the repository at this point in the history
  • Loading branch information
ohaibbq authored Jul 1, 2024
1 parent ed459f5 commit 9d65c7d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func newAnalyzerOptions() (*zetasql.AnalyzerOptions, error) {
zetasql.FeatureV11WithOnSubquery,
zetasql.FeatureV13Pivot,
zetasql.FeatureV13Unpivot,
zetasql.FeatureCreateTableAsSelectColumnList,
})
langOpt.SetSupportedStatementKinds([]ast.Kind{
ast.BeginStmt,
Expand Down
11 changes: 11 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5887,6 +5887,17 @@ SELECT c1 * ? * ? FROM t1;
args: []interface{}{int64(1), int64(2), int64(3)},
expectedRows: [][]interface{}{{int64(6)}},
},
{
name: "create table as select with column list",
query: `
CREATE TABLE table1 (field_a STRING NOT NULL);
INSERT INTO table1 (field_a) VALUES ("test");
CREATE TEMP TABLE table2 (field_x STRING NOT NULL)
AS (SELECT field_a FROM table1);
SELECT * FROM table2;
`,
expectedRows: [][]interface{}{{"test"}},
},
} {
test := test
t.Run(test.name, func(t *testing.T) {
Expand Down

0 comments on commit 9d65c7d

Please sign in to comment.