Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BREAKING] Implicit cast rules for integer literals, and parameterized ANY for binding #10194

Merged
merged 14 commits into from
Jan 10, 2024
Next Next commit
Fix #10096 - prefer auto-casting to HUGEINT over DOUBLE to prevent lo…
…ss of precision
  • Loading branch information
Mytherin committed Jan 9, 2024
commit 4beb4f91fdf3b4f1f1d3299af2c690273af52678
12 changes: 6 additions & 6 deletions src/function/cast_rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ namespace duckdb {
//! The target type determines the preferred implicit casts
static int64_t TargetTypeCost(const LogicalType &type) {
switch (type.id()) {
case LogicalTypeId::INTEGER:
return 103;
case LogicalTypeId::BIGINT:
return 101;
case LogicalTypeId::DOUBLE:
case LogicalTypeId::INTEGER:
return 102;
case LogicalTypeId::HUGEINT:
return 120;
return 103;
case LogicalTypeId::DOUBLE:
return 104;
case LogicalTypeId::DECIMAL:
return 105;
case LogicalTypeId::TIMESTAMP_NS:
return 119;
case LogicalTypeId::TIMESTAMP:
Expand All @@ -23,8 +25,6 @@ static int64_t TargetTypeCost(const LogicalType &type) {
return 122;
case LogicalTypeId::VARCHAR:
return 149;
case LogicalTypeId::DECIMAL:
return 104;
case LogicalTypeId::STRUCT:
case LogicalTypeId::MAP:
case LogicalTypeId::LIST:
Expand Down
1 change: 1 addition & 0 deletions src/parser/transform/expression/transform_constant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace duckdb {


unique_ptr<ConstantExpression> Transformer::TransformValue(duckdb_libpgquery::PGValue val) {
switch (val.type) {
case duckdb_libpgquery::T_PGInteger:
Expand Down
12 changes: 12 additions & 0 deletions test/sql/types/numeric/ubigint_arithmetic_casting.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# name: test/sql/types/numeric/ubigint_arithmetic_casting.test
# description: UBIGINT arithmetic
# group: [numeric]

statement ok
PRAGMA enable_verification

# ubigint casts
query I
SELECT typeof(1::UBIGINT + 1::TINYINT)
----
HUGEINT