Skip to content

Commit

Permalink
Merge pull request #358 from egillax/duckdb_random_uuid
Browse files Browse the repository at this point in the history
add duckdb NEWID() mapping and a test
  • Loading branch information
schuemie authored Jan 26, 2024
2 parents 5a6f050 + 98d760d commit 39c95b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inst/csv/replacementPatterns.csv
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ duckdb,"ISNULL(@a,@b)","COALESCE(@a,@b)"
duckdb,"ISNUMERIC(@a)","CASE WHEN (CAST(@a AS VARCHAR) ~ '^([0-9]+\.?[0-9]*|\.[0-9]+)$') THEN 1 ELSE 0 END"
duckdb,COUNT_BIG(@a),COUNT(@a)
duckdb,SQUARE(@a),((@a)*(@a))
duckdb,NEWID(),MD5(RANDOM()::TEXT || CLOCK_TIMESTAMP()::TEXT)
duckdb,NEWID(),uuid()
duckdb,USE @schema;,SET search_path TO @schema;
duckdb,"IF OBJECT_ID('@table', 'U') IS NULL CREATE TABLE @table (@definition);",CREATE TABLE IF NOT EXISTS @table (@definition);
duckdb,"IF OBJECT_ID('@table', 'U') IS NOT NULL DROP TABLE @table;",DROP TABLE IF EXISTS @table;
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-translate-duckdb.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,7 @@ test_that("translate sql server -> DuckDB add days with period", {
"(date + TO_DAYS(CAST(-2.0 AS INTEGER)))"
)
})
test_that("translate sql server -> duckdb NEWID", {
sql <- translate("SELECT NEWID()", targetDialect = "duckdb")
expect_equal_ignore_spaces(sql, "SELECT uuid()")
})

0 comments on commit 39c95b4

Please sign in to comment.