You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: NEWS.md
+8
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,11 @@
1
+
SqlRender 1.19.2
2
+
================
3
+
4
+
Bugfixes:
5
+
6
+
1. On DataBricks, a translation of `DATEADD()` now returns a `DATE` if the input was a `DATE`, to be consistent with other platforms. (Requires input field name to end with '_date')
Copy file name to clipboardexpand all lines: tests/testthat/test-translate-spark.R
+18-3
Original file line number
Diff line number
Diff line change
@@ -422,17 +422,17 @@ test_that("translate sql server -> spark DATEADD DAY with float", {
422
422
sql<- translate("select DATEADD(DAY, 1.0, some_date) from my_table;",
423
423
targetDialect="spark"
424
424
)
425
-
expect_equal_ignore_spaces(sql, "select DATEADD(DAY, 1, some_date) from my_table;")
425
+
expect_equal_ignore_spaces(sql, "select CAST(DATEADD(DAY, 1, some_date) AS DATE) from my_table;")
426
426
})
427
427
428
428
test_that("translate sql server -> spark DATEADD YEAR with float", {
429
429
sql<- translate("select DATEADD(YEAR, 1.0, some_date) from my_table;",
430
430
targetDialect="spark"
431
431
)
432
-
expect_equal_ignore_spaces(sql, "select DATEADD(YEAR, 1, some_date) from my_table;")
432
+
expect_equal_ignore_spaces(sql, "select CAST(DATEADD(YEAR, 1, some_date) AS DATE) from my_table;")
433
433
})
434
434
435
-
test_that("translate sql server -> spark DATEADD YEAR with float", {
435
+
test_that("translate sql server -> spark CTE", {
436
436
sql<- translate("WITH cte AS (SELECT * FROM table) SELECT * INTO tmp.table FROM cte;",
437
437
targetDialect="spark"
438
438
)
@@ -468,3 +468,18 @@ test_that("translate sql server -> spark create temp table if not exists", {
468
468
sql<- translate("CREATE TABLE IF NOT EXISTS #temp (x INT);", targetDialect="spark", tempEmulationSchema="ts")
469
469
expect_equal_ignore_spaces(sql, sprintf("CREATE TABLE IF NOT EXISTS ts.%stemp \nUSING DELTA\n AS\nSELECT\nCAST(NULL AS int) AS x WHERE 1 = 0;", getTempTablePrefix()))
0 commit comments