Skip to content

Commit

Permalink
Support parsing SQL Server INSERT INTO sql (#29842)
Browse files Browse the repository at this point in the history
* create first insert test case

* complete first insert test case

* complete second insert test case
  • Loading branch information
KonarzewskiP authored Jan 25, 2024
1 parent 57cf619 commit 696f496
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
33 changes: 33 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 @@ -3380,4 +3380,37 @@
</from>
</select>
</insert>

<insert sql-case-id="insert_into_table_get_date">
<table name="#Test" start-index="12" stop-index="16"/>
<columns start-index="17" stop-index="17"/>
<values>
<value>
<assignment-value>
<literal-expression value="OC" start-index="26" stop-index="30"/>
</assignment-value>
<assignment-value>
<literal-expression value="Ounces" start-index="33" stop-index="41"/>
</assignment-value>
<assignment-value>
<function function-name="GETDATE" text="GETDATE()" start-index="44" stop-index="52" />
</assignment-value>
</value>
</values>
</insert>

<insert sql-case-id="insert_into_table_from_table">
<table name="#Test" start-index="12" stop-index="16"/>
<columns start-index="17" stop-index="17"/>
<select>
<projections start-index="25" stop-index="25">
<shorthand-projection start-index="25" stop-index="25"/>
</projections>
<from>
<simple-table name="UnitMeasure" start-index="32" stop-index="53">
<owner name="Production" start-index="32" stop-index="41"/>
</simple-table>
</from>
</select>
</insert>
</sql-parser-test-cases>
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,6 @@
<sql-case id="insert_with_currency_value" value="INSERT INTO [HR].[Employees]([SSN], [FirstName], [LastName], [Salary]) VALUES ('795-73-9838', N'Catherine', N'Abel', $31692)" db-types="SQLServer"/>
<sql-case id="insert_with_select_from_open_row_1" value="INSERT INTO myTable(FileName, FileType, Document) SELECT 'Text1.txt' AS FileName, '.txt' AS FileType, * FROM OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB) AS Document" db-types="SQLServer"/>
<sql-case id="insert_with_select_from_open_row_2" value="INSERT INTO achievements with (TABLOCK) (id, description) SELECT * FROM OPENROWSET(BULK 'csv/achievements.csv', DATA_SOURCE = 'MyAzureBlobStorage', FORMAT ='CSV', FORMATFILE='csv/achievements-c.xml', FORMATFILE_DATA_SOURCE = 'MyAzureBlobStorage') AS DataFile" db-types="SQLServer"/>
<sql-case id="insert_into_table_get_date" value="INSERT INTO #Test VALUES (N'OC', N'Ounces', GETDATE())" db-types="SQLServer"/>
<sql-case id="insert_into_table_from_table" value="INSERT INTO #Test SELECT * FROM Production.UnitMeasure" db-types="SQLServer"/>
</sql-cases>

0 comments on commit 696f496

Please sign in to comment.