Skip to content

Conversation

@wForget
Copy link

@wForget wForget commented Dec 12, 2025

What changes are proposed in this pull request, and why are they necessary?

Support insert into/overwrite table for hive.

  1. A new RichSqlInsert class extends SqlInsert by adding two fields: extendedKeywords, which represents the OVERWRITE keyword, and partitions, which represents the insert partition specification.
  2. Add support for building insert statement to ParseTreeBuilder
TOK_QUERY              ---  Set SqlSelect to RichSqlInsert.source
   TOK_FROM
      TOK_TABREF
         TOK_TABNAME
            test
            tableTwo
   TOK_INSERT
      TOK_INSERT_INTO   --- Create RichSqlInsert and set to ParseContext.insert
         TOK_TAB
            TOK_TABNAME
               test
               tableTwoPart
            TOK_PARTSPEC
               TOK_PARTVAL
                  p1
                  'p1'
               TOK_PARTVAL
                  p2
                  2
      TOK_SELECT
         TOK_SELEXPR
            TOK_TABLE_OR_COL
               x
         TOK_SELEXPR
            TOK_TABLE_OR_COL
               y

closes #565

How was this patch tested?

Added test cases

public void testInsertInto() {
String input = "INSERT INTO db.table PARTITION(dt='2025-12-11', hour) SELECT a, b, hour FROM t";
String expected =
"insert into `db`.`table` partition (`dt` = '2025-12-11', `hour`) (select `a`, `b`, `hour` from `t`)";
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SqlNode to SQL added unnecessary parentheses, related to https://issues.apache.org/jira/browse/CALCITE-5265

@wForget wForget changed the title feat: Support insert table for hive feat(hive): Support insert table for hive Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(hive): Support insert into/overwrite for hive

1 participant