Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ duckdb_unittest_tempdir/
testext
test/python/__pycache__/
.Rhistory
_codeql_build_dir/
_codeql_detected_source_root
2 changes: 2 additions & 0 deletions chsql/src/chsql_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ namespace duckdb
{DEFAULT_SCHEMA, "toYYYYMMDD", {"date_expression", nullptr}, {{nullptr, nullptr}}, R"(DATE_FORMAT(date_expression, '%Y%m%d'))"},
{DEFAULT_SCHEMA, "toYYYYMMDDhhmmss", {"date_expression", nullptr}, {{nullptr, nullptr}}, R"(DATE_FORMAT(date_expression, '%Y%m%d%H%M%S'))"},
{DEFAULT_SCHEMA, "formatDateTime", {"time", "format", "timezone", nullptr}, {{nullptr, nullptr}}, R"(CASE WHEN timezone IS NULL THEN strftime(time, format) ELSE strftime(time AT TIME ZONE timezone, format) END)"},
{DEFAULT_SCHEMA, "toUnixTimestamp", {"date_expression", nullptr}, {{nullptr, nullptr}}, R"(CAST(EXTRACT(EPOCH FROM date_expression) AS BIGINT))"},
{DEFAULT_SCHEMA, "fromUnixTimestamp", {"unix_timestamp", nullptr}, {{nullptr, nullptr}}, R"(CAST(to_timestamp(unix_timestamp) AS TIMESTAMP))"},
// String Functions
{DEFAULT_SCHEMA, "empty", {"str", nullptr}, {{nullptr, nullptr}}, R"(LENGTH(str) = 0)"},
{DEFAULT_SCHEMA, "notEmpty", {"str", nullptr}, {{nullptr, nullptr}}, R"(LENGTH(str) > 0)"},
Expand Down
10 changes: 10 additions & 0 deletions chsql/test/sql/chsql.test
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ SELECT toDayOfMonth('2023-05-15'::DATE)
----
15

query I
SELECT toUnixTimestamp('2023-05-15 10:30:45'::TIMESTAMP)
----
1684146645

query I
SELECT fromUnixTimestamp(1684146645)
----
2023-05-15 10:30:45

# String Functions
query I
SELECT empty('')
Expand Down
Loading