Skip to content

Commit

Permalink
Merge pull request #344 from OHDSI/issue-343-databricks-delete-fix
Browse files Browse the repository at this point in the history
Remove delete/insert translation rules for Databricks
  • Loading branch information
schuemie authored Sep 30, 2023
2 parents 28e71d0 + c806a47 commit 8fcaa36
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
3 changes: 0 additions & 3 deletions inst/csv/replacementPatterns.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1039,8 +1039,6 @@ spark,#@([^\s]+)table.@([^\s]+)field,%session_id%@table.@field
spark,#,%temp_prefix%%session_id%
spark,"--HINT BUCKET(@a, @b)",
spark,"--HINT PARTITION(@a @b)",
spark,"INSERT INTO @table (@columns) SELECT @values;","WITH insertion_temp AS (\n(SELECT @values) UNION ALL (SELECT @columns FROM @table))\nINSERT OVERWRITE TABLE @table (@columns) SELECT * FROM insertion_temp;"
spark,"INSERT INTO @table (@columns) VALUES @values;","WITH insertion_temp AS (\n(SELECT * FROM VALUES @values T(@columns)) UNION ALL (SELECT @columns FROM @table))\nINSERT OVERWRITE TABLE @table (@columns) SELECT * FROM insertion_temp;"
spark,"HINT DISTRIBUTE_ON_KEY(@key) CREATE TABLE IF NOT EXISTS @table\nUSING DELTA\nAS\n@definition;","HINT DISTRIBUTE_ON_KEY(@key)\nCREATE TABLE IF NOT EXISTS @table\nUSING DELTA\nAS\n@definition;\nOPTIMIZE @table ZORDER BY @key;"
spark,"HINT DISTRIBUTE_ON_KEY(@key) IF OBJECT_ID('@d', 'U') IS NULL WITH @a AS @b SELECT @c INTO @d FROM @e;",HINT DISTRIBUTE_ON_KEY(@key)\nCREATE TABLE IF NOT EXISTS @d\nUSING DELTA\nAS\nWITH @a AS @b SELECT\n@c\nFROM\n@e;\nOPTIMIZE @d ZORDER BY @key;
spark,"HINT DISTRIBUTE_ON_KEY(@key) IF OBJECT_ID('@b', 'U') IS NULL SELECT @a INTO @b FROM @c;",HINT DISTRIBUTE_ON_KEY(@key) \nCREATE TABLE IF NOT EXISTS @b\nUSING DELTA\nAS\nSELECT\n@a\nFROM\n@c;\nOPTIMIZE @b ZORDER BY @key;
Expand Down Expand Up @@ -1130,7 +1128,6 @@ spark,(SELECT DISTINCT TOP @([0-9]+)rows @a),(SELECT DISTINCT @a LIMIT @rows)
spark,"WITH @cte AS (SELECT @s1 '@literal' @s2)","WITH @cte AS (SELECT @s1 CAST('@literal' as STRING) @s2)"
spark,UPDATE STATISTICS @a;,
spark,"SELECT @columns FROM (@a) @x,(@b) @y;","SELECT @columns FROM (@a) @x cross join (@b) @y;"
spark,DELETE FROM @a WHERE @b;,INSERT OVERWRITE TABLE @a SELECT * FROM @a WHERE NOT (@b);
sqlite extended,"IIF(@condition, @whentrue, @whenfalse)","CASE WHEN @condition THEN @whentrue ELSE @whenfalse END"
sqlite extended,"ROUND(@a,@b)","ROUND(CAST(@a AS REAL),@b)"
sqlite extended,+ '@a',|| '@a'
Expand Down
29 changes: 0 additions & 29 deletions tests/testthat/test-translate-spark.R
Original file line number Diff line number Diff line change
Expand Up @@ -376,35 +376,6 @@ test_that("translate sql server -> spark DROP TABLE IF EXISTS", {
expect_equal_ignore_spaces(sql, "DROP TABLE IF EXISTS test;")
})

test_that("translate sql server -> spark INSERT INTO SELECT", {
sql <- translate("INSERT INTO a (b int) SELECT c FROM cte1;",
targetDialect = "spark"
)
expect_equal_ignore_spaces(
sql,
"WITH insertion_temp AS (\n(SELECT c FROM cte1) UNION ALL (SELECT b int FROM a ))\nINSERT OVERWRITE TABLE a (b int) SELECT * FROM insertion_temp;"
)
})

test_that("translate sql server -> spark INSERT INTO VALUES", {
sql <- translate("INSERT INTO my_table (key,value) VALUES (1,0),(2,0),(3,1);",
targetDialect = "spark"
)
expect_equal_ignore_spaces(
sql,
"WITH insertion_temp AS (\n(SELECT * FROM VALUES (1,0),(2,0),(3,1) T(key,value)) UNION ALL (SELECT key,value FROM my_table ))\nINSERT OVERWRITE TABLE my_table (key,value) SELECT * FROM insertion_temp;"
)
})

test_that("translate sql server -> spark DELETE FROM WHERE", {
sql <- translate("DELETE FROM my_table WHERE a=1;",
targetDialect = "spark"
)
expect_equal_ignore_spaces(
sql,
"INSERT OVERWRITE TABLE my_table SELECT * FROM my_table WHERE NOT (a=1);"
)
})
test_that("translate sql server -> spark double CTE INSERT INTO", {
sql <- translate(
"WITH a AS (
Expand Down

0 comments on commit 8fcaa36

Please sign in to comment.