huaxingao opened a new pull request #29324:
URL: https://github.com/apache/spark/pull/29324


   ### What changes were proposed in this pull request?
   Implement ALTER TABLE in JDBC Table Catalog
   The following ALTER TABLE are implemented:
   ```
   ALTER TABLE table_name ADD COLUMNS ( column_name datatype [ , ... ] );
   ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name;
   ALTER TABLE table_name DROP COLUMN column_name;
   ```
   I haven't checked ALTER TABLE syntax for all the databases yet. I will 
check. If there are different syntax, I will have a follow-up to override the 
dialect. 
   
   Seems most of the databases don't support `ALTER TABLE table_name ADD 
COLUMNS` with the options of specifying nullability, comment and the position 
of the new column, so I didn't implement these options.
   
   Updating column data type seems not supported, I got a parser error for the 
following sql statement:
   ```
   ALTER TABLE h2.test.alt_table ALTER COLUMN id DOUBLE
   ----------------------------------------------^^^
   
        at 
org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:263)
   ```
   Seems most of the databases don't support updating nullability, comments and 
column position, so I didn't implement UpdateColumn.
   
    
   
   ### Why are the changes needed?
   Complete the JDBCTableCatalog implementation
   
   
   ### Does this PR introduce _any_ user-facing change?
   Yes
   `JDBCTableCatalog.alterTable`
   
   
   ### How was this patch tested?
   add new tests
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to