From 9d65c7df351bc4b9056c6610acffdfbcdfc8c1b9 Mon Sep 17 00:00:00 2001 From: Dan Hansen Date: Mon, 1 Jul 2024 03:39:23 -0700 Subject: [PATCH] Support create table as select with column list (#214) --- internal/analyzer.go | 1 + query_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/internal/analyzer.go b/internal/analyzer.go index fa0aac6..7274d29 100644 --- a/internal/analyzer.go +++ b/internal/analyzer.go @@ -75,6 +75,7 @@ func newAnalyzerOptions() (*zetasql.AnalyzerOptions, error) { zetasql.FeatureV11WithOnSubquery, zetasql.FeatureV13Pivot, zetasql.FeatureV13Unpivot, + zetasql.FeatureCreateTableAsSelectColumnList, }) langOpt.SetSupportedStatementKinds([]ast.Kind{ ast.BeginStmt, diff --git a/query_test.go b/query_test.go index a7541d1..39a1d0d 100644 --- a/query_test.go +++ b/query_test.go @@ -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) {