iffyio commented on code in PR #2279:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2279#discussion_r2965536660


##########
src/parser/mod.rs:
##########
@@ -8374,7 +8374,15 @@ impl<'a> Parser<'a> {
         };
 
         // parse optional column list (schema)
-        let (columns, constraints) = self.parse_columns()?;
+        // Redshift CTAS allows column names without types:
+        //   CREATE TABLE t (col1, col2) AS SELECT 1, 2
+        // Detect this by peeking for `( ident ,` or `( ident )` patterns.
+        let (columns, constraints) =
+            if dialect_of!(self is RedshiftSqlDialect) && 
self.peek_column_names_only() {

Review Comment:
   Can we convert this into a dialect method?
   
   Actually looking at the code this feature seems to be solving a similar 
problem to `is_column_type_sqlite_unspecified` - likely we can instead have 
that `parse_column_def` function optionally accept a datatype if this method is 
true (and can rename the method accordingly)



##########
tests/sqlparser_redshift.rs:
##########
@@ -500,3 +500,15 @@ fn test_alter_table_alter_sortkey() {
     redshift().verified_stmt("ALTER TABLE users ALTER SORTKEY(created_at)");
     redshift().verified_stmt("ALTER TABLE users ALTER SORTKEY(c1, c2)");
 }
+
+#[test]
+fn test_create_table_as_with_column_names() {
+    redshift().verified_stmt(
+        "CREATE TEMPORARY TABLE volt_tt (userid, days_played_in_last_31) AS 
SELECT 1, 2",
+    );
+    // TEMP is an alias for TEMPORARY
+    redshift().one_statement_parses_to(
+        "CREATE TEMP TABLE volt_tt(userid, days_played_in_last_31) AS SELECT 
1, 2",
+        "CREATE TEMPORARY TABLE volt_tt (userid, days_played_in_last_31) AS 
SELECT 1, 2",

Review Comment:
   this test/PR isn't related to temporary tables? if so it would probably be 
better to remove the temp qualifiers and we can use `verified_stmt` as usual?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to