Skip to content
Merged
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
651 changes: 326 additions & 325 deletions src/generated/generated_temporal_udfs_0.cpp

Large diffs are not rendered by default.

2,385 changes: 1,163 additions & 1,222 deletions src/generated/generated_temporal_udfs_1.cpp

Large diffs are not rendered by default.

1,929 changes: 967 additions & 962 deletions src/generated/generated_temporal_udfs_2.cpp

Large diffs are not rendered by default.

1,456 changes: 821 additions & 635 deletions src/generated/generated_temporal_udfs_3.cpp

Large diffs are not rendered by default.

1,972 changes: 908 additions & 1,064 deletions src/generated/generated_temporal_udfs_4.cpp

Large diffs are not rendered by default.

2,705 changes: 1,343 additions & 1,362 deletions src/generated/generated_temporal_udfs_5.cpp

Large diffs are not rendered by default.

3,897 changes: 1,978 additions & 1,919 deletions src/generated/generated_temporal_udfs_6.cpp

Large diffs are not rendered by default.

3,758 changes: 1,967 additions & 1,791 deletions src/generated/generated_temporal_udfs_7.cpp

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions test/sql/parity/027_tjsonb.test
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ SELECT tint(TJSONB('{"a":1}@2000-01-01'), 'a', 'use_json_null')::VARCHAR,
----
1@2000-01-01 00:00:00+01 t@2000-01-01 00:00:00+01 "x"@2000-01-01 00:00:00+01

# The mode may be left out, and the call answers what it answers with MobilityDB's default mode
query III
SELECT tint(TJSONB('{"a":1}@2000-01-01'), 'a') = tint(TJSONB('{"a":1}@2000-01-01'), 'a', 'raise_exception'),
tbool(TJSONB('{"b":true}@2000-01-01'), 'b') = tbool(TJSONB('{"b":true}@2000-01-01'), 'b', 'raise_exception'),
ttext(TJSONB('{"c":"x"}@2000-01-01'), 'c') = ttext(TJSONB('{"c":"x"}@2000-01-01'), 'c', 'raise_exception');
----
true true true

# The mode is parsed by MEOS, so an unknown one is its error rather than a silent default.
statement error
SELECT tint(TJSONB('{"a":1}@2000-01-01'), 'a', 'not_a_mode');
Expand Down
14 changes: 14 additions & 0 deletions test/sql/tint.test
Original file line number Diff line number Diff line change
Expand Up @@ -637,3 +637,17 @@ query I
SELECT tbigintFromHexWKB(asHexWKB(tbigint '42@2000-01-01')) = tbigint '42@2000-01-01';
----
true

# A trailing argument MobilityDB declares with a default may be left out, and the shorter call
# answers what the full call answers with that default
query I
SELECT deleteTime(tint '[1@2001-01-01, 2@2001-01-02, 3@2001-01-03]', timestamptz '2001-01-02') =
deleteTime(tint '[1@2001-01-01, 2@2001-01-02, 3@2001-01-03]', timestamptz '2001-01-02', true);
----
true

query I
SELECT afterTimestamp(tint '[1@2001-01-01, 2@2001-01-03]', timestamptz '2001-01-02') =
afterTimestamp(tint '[1@2001-01-01, 2@2001-01-03]', timestamptz '2001-01-02', true);
----
true
58 changes: 58 additions & 0 deletions tools/codegen_duck_udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,34 @@ def emit_defaulted_unary_temporal(name, subcast, dval):
f" return TemporalToBlobN(result, r, mask, idx);\n"
f" }});\n}}\n")

def emit_defaulted_ternary(f, kind, arg2, dval):
"""The shorter (Temporal, scalar)->X overload of a (Temporal, scalar, scalar-param
DEFAULT)->X function (tquadbin(tgeompoint, integer[, borderInc boolean DEFAULT TRUE])): the
body of #emit_body_ternary with the trailing default substituted, over a BinaryExecutor, as
#emit_defaulted_unary_temporal is the shorter overload of a binary function."""
name = f["name"]; dt2, cpp2, _ = arg2
e2 = arg2[2]
if kind == "temporal":
return (f"static void Gen_{name}_d(DataChunk &args, ExpressionState &, Vector &result) {{\n"
f" EnsureMeosThreadInitialized();\n"
f" BinaryExecutor::ExecuteWithNulls<string_t, {cpp2}, string_t>("
f"args.data[0], args.data[1], result, args.size(),\n"
f" [&](string_t in, {cpp2} a2, ValidityMask &mask, idx_t idx) -> string_t {{\n"
f" Temporal *t = BlobToTemporal(in);\n"
f" Temporal *r = {name}(t, {e2}, {dval});\n free(t);\n"
f" return TemporalToBlobN(result, r, mask, idx);\n }});\n}}\n")
ctype, rett, _rx = scalar_emit3(f)
ex, prm, ann, ret = scalar_exec(f, rett, _rx)
return (f"static void Gen_{name}_d(DataChunk &args, ExpressionState &, Vector &result) {{\n"
f" EnsureMeosThreadInitialized();\n"
f" BinaryExecutor::{ex}<string_t, {cpp2}, {rett}>("
f"args.data[0], args.data[1], result, args.size(),\n"
f" [&](string_t in, {cpp2} a2{prm}){ann} {{\n"
f" Temporal *t = BlobToTemporal(in);\n"
f" {ctype} r = {name}(t, {e2}, {dval});\n free(t);\n"
f" {ret}\n"
f" }});\n}}\n")

def emit_defaulted_unary_temporal_scalar(f, dval):
"""The shorter (Temporal)->scalar overload of a (Temporal, scalar-param DEFAULT)->scalar
function (duration(temporal[,boolean]), asText/asEWKT(tspatial[,int])): a UnaryExecutor
Expand Down Expand Up @@ -4191,6 +4219,36 @@ def gen_cpp(fns, out_path, declared=None, aliases=None):
for nm in names:
specific_regs.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction('
f'"{reg_name(nm, f)}", {{{a}}}, {r2}, Gen_{fn}_d));')
# A (temporal, scalar, scalar-param DEFAULT)->X fn (tquadbin(tgeompoint, integer[,
# borderInc DEFAULT TRUE])) is callable one argument shorter too: the same overload one
# position up, the binary body with the trailing default substituted.
if t and trailing_arg_default(f):
# The default reaches the kernel the way the argument it stands for does: a by-value
# scalar as its C++ literal, a text argument through the marshalling its column takes
# (null_handle_type_from_string of 'raise_exception'), the literal as its string_t.
_raw = trailing_arg_default(f)
_a3 = t[3]
if _a3[1] == "string_t":
_lit = '"%s"' % _raw.strip().strip("'")
dflt = _a3[2].replace("a2", "string_t(%s)" % _lit)
else:
dflt = sql_default_to_cpp(_raw)
bodies.append(emit_defaulted_ternary(f, kind, arg2, dflt))
if scope == "all":
rett = (ret_temporal_type(fn, "type", f.get("group"), f.get("sqlReturnType"))
if dret == "MD_TEMPORAL" else dret)
for nm in names:
generic_regs.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction('
f'"{reg_name(nm, f)}", {{type, {arg2[0]}}}, {rett}, Gen_{fn}_d));')
else:
for a in accs:
r2 = dret
if dret == "MD_TEMPORAL":
r2 = (sig_declared_ret(f, a, 2)
or ret_temporal_type(fn, a, f.get("group"), f.get("sqlReturnType")))
for nm in names:
specific_regs.append(f' RegisterSerializedScalarFunction(loader, ScalarFunction('
f'"{reg_name(nm, f)}", {{{a}, {arg2[0]}}}, {r2}, Gen_{fn}_d));')
# Same shorter-arity overload for a (Temporal, scalar-param DEFAULT)->SCALAR fn
# (duration(temporal[,boolean]) DEFAULT FALSE; asText/asEWKT(tspatial[,int]) DEFAULT 15):
# the 1-arg form is canonical SQL but geo-only-hand today — generate it for every type
Expand Down
Loading