-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update vendored DuckDB sources to 16f4045
- Loading branch information
1 parent
16f4045
commit 27b464e
Showing
45 changed files
with
368 additions
and
309 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include "include/icu-dateadd.hpp" | ||
|
||
#include "duckdb/main/extension_util.hpp" | ||
#include "duckdb/common/types/time.hpp" | ||
#include "duckdb/common/types/timestamp.hpp" | ||
#include "duckdb/parser/parsed_data/create_scalar_function_info.hpp" | ||
#include "duckdb/planner/expression/bound_function_expression.hpp" | ||
#include "duckdb/transaction/meta_transaction.hpp" | ||
#include "include/icu-current.hpp" | ||
#include "include/icu-casts.hpp" | ||
|
||
namespace duckdb { | ||
|
||
static timestamp_t GetTransactionTimestamp(ExpressionState &state) { | ||
return MetaTransaction::Get(state.GetContext()).start_timestamp; | ||
} | ||
|
||
static void CurrentTimeFunction(DataChunk &input, ExpressionState &state, Vector &result) { | ||
D_ASSERT(input.ColumnCount() == 0); | ||
auto instant = GetTransactionTimestamp(state); | ||
ICUDateFunc::BindData data(state.GetContext()); | ||
|
||
dtime_tz_t result_time(dtime_t(0), 0); | ||
ICUToTimeTZ::ToTimeTZ(data.calendar.get(), instant, result_time); | ||
auto val = Value::TIMETZ(result_time); | ||
result.Reference(val); | ||
} | ||
|
||
static void CurrentDateFunction(DataChunk &input, ExpressionState &state, Vector &result) { | ||
D_ASSERT(input.ColumnCount() == 0); | ||
auto instant = GetTransactionTimestamp(state); | ||
|
||
auto val = Value::DATE(ICUMakeDate::ToDate(state.GetContext(), instant)); | ||
result.Reference(val); | ||
} | ||
|
||
ScalarFunction GetCurrentTimeFun() { | ||
ScalarFunction current_time({}, LogicalType::TIME_TZ, CurrentTimeFunction); | ||
current_time.stability = FunctionStability::CONSISTENT_WITHIN_QUERY; | ||
return current_time; | ||
} | ||
|
||
ScalarFunction GetCurrentDateFun() { | ||
ScalarFunction current_date({}, LogicalType::DATE, CurrentDateFunction); | ||
current_date.stability = FunctionStability::CONSISTENT_WITHIN_QUERY; | ||
return current_date; | ||
} | ||
|
||
void RegisterICUCurrentFunctions(DatabaseInstance &db) { | ||
// temporal + interval | ||
ScalarFunctionSet current_time("get_current_time"); | ||
current_time.AddFunction(GetCurrentTimeFun()); | ||
ExtensionUtil::RegisterFunction(db, current_time); | ||
|
||
ScalarFunctionSet current_date("current_date"); | ||
current_date.AddFunction(GetCurrentDateFun()); | ||
ExtensionUtil::RegisterFunction(db, current_date); | ||
|
||
current_date.name = "today"; | ||
ExtensionUtil::RegisterFunction(db, current_date); | ||
} | ||
|
||
} // namespace duckdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.