Skip to content

Commit

Permalink
Support parsing SQL Server INSERT INTO sql apache#29195
Browse files Browse the repository at this point in the history
  • Loading branch information
yydeng626 committed Jan 30, 2024
1 parent 5ab48b2 commit 07a6a68
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/it/parser/src/main/resources/case/dml/insert.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3457,4 +3457,31 @@
</columns>
<exec name="predict_per_partition" start-index="129" stop-index="159" start-delimiter="[" end-delimiter="]" />
</insert>

<insert sql-case-id="insert_with_table_t">
<table name="#t" start-index="12" stop-index="13" />
<columns start-index="14" stop-index="14" />
<values>
<value>
<assignment-value>
<literal-expression value="99" start-index="23" stop-index="24" />
</assignment-value>
</value>
</values>
</insert>

<insert sql-case-id="insert_with_table_test">
<table name="##test" start-index="12" stop-index="17" />
<columns start-index="18" stop-index="18" />
<values>
<value>
<assignment-value>
<literal-expression value="1" start-index="27" stop-index="27" />
</assignment-value>
<assignment-value>
<literal-expression value="1" start-index="30" stop-index="30" />
</assignment-value>
</value>
</values>
</insert>
</sql-parser-test-cases>
44 changes: 44 additions & 0 deletions test/it/parser/src/main/resources/case/dml/select.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8227,4 +8227,48 @@
</collection-table>
</from>
</select>

<select sql-case-id="select_from_table_test">
<projections start-index="7" stop-index="7">
<shorthand-projection start-index="7" stop-index="7" />
</projections>
<from>
<simple-table name="##test" start-index="14" stop-index="19" />
</from>
</select>

<select sql-case-id="select_from_table_openrowset">
<projections start-index="7" stop-index="45">
<top-projection start-index="7" stop-index="13">
<top-value value="100" start-index="11" stop-index="13" />
</top-projection>
<expression-projection text="CAST(_id as VARBINARY(1000))" alias="id" start-index="15" stop-index="45">
<expr>
<function function-name="CAST" text="CAST(_id as VARBINARY(1000))" start-index="18" stop-index="45">
<parameter>
<column name="_id" start-index="23" stop-index="25" />
</parameter>
<parameter>
<data-type value="VARBINARY" start-index="30" stop-index="44" />
</parameter>
</function>
</expr>
</expression-projection>
</projections>
<from start-index="52" stop-index="130">
<function-table start-index="52" stop-index="130">
<table-function function-name="OPENROWSET" text="OPENROWSET('CosmosDB', 'Your-account;Database=your-database;Key=your-key',HTAP)">
<parameter>
<literal-expression value="CosmosDB" start-index="63" stop-index="72" />
</parameter>
<parameter>
<literal-expression value="Your-account;Database=your-database;Key=your-key" start-index="75" stop-index="124" />
</parameter>
<parameter>
<literal-expression value="HTAP" start-index="126" stop-index="129" />
</parameter>
</table-function>
</function-table>
</from>
</select>
</sql-parser-test-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,6 @@
<sql-case id="insert_into_table_from_table" value="INSERT INTO #Test SELECT * FROM Production.UnitMeasure" db-types="SQLServer"/>
<sql-case id="insert_into_production_location" value="INSERT INTO AdventureWorks2022.Production.Location(Name, CostRate, Availability, ModifiedDate) VALUES (NEWID(), .5, 5.2, GETDATE())" db-types="SQLServer"/>
<sql-case id="insert_with_exec_prediction_results" value="INSERT INTO prediction_results (tipped_Pred,payment_type,tipped,passenger_count,trip_distance,trip_time_in_secs,direct_distance) EXECUTE [predict_per_partition]" db-types="SQLServer"/>
<sql-case id="insert_with_table_t" value="INSERT INTO #t VALUES (99)" db-types="SQLServer"/>
<sql-case id="insert_with_table_test" value="INSERT INTO ##test VALUES (1, 1)" db-types="SQLServer"/>
</sql-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,6 @@
<sql-case id="select_from_dbms_table" value="select * from table(dbms_xplan.display);" db-types="Oracle"/>
<sql-case id="select_from_database_files" value="SELECT name, size / 128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT) / 128.0 AS AvailableSpaceInMB FROM sys.database_files" db-types="SQLServer"/>
<sql-case id="select_trim_2" value="SELECT TRIM( ' test ') AS Result" db-types="SQLServer"/>
<sql-case id="select_from_table_test" value="SELECT * FROM ##test" db-types="SQLServer"/>
<sql-case id="select_from_table_openrowset" value="SELECT TOP 100 id=CAST(_id as VARBINARY(1000)) FROM OPENROWSET('CosmosDB', 'Your-account;Database=your-database;Key=your-key',HTAP) WITH (_id VARCHAR(1000)) as HTAP" db-types="SQLServer"/>
</sql-cases>

0 comments on commit 07a6a68

Please sign in to comment.