Fix executable user default functions execution with Nullable arguments

This commit is contained in:
Maksim Kita 2022-05-31 18:46:33 +02:00
parent bacee7f19c
commit 66f43b9ad3
4 changed files with 47 additions and 1 deletions

View File

@ -43,7 +43,7 @@ public:
size_t getNumberOfArguments() const override { return executable_function->getConfiguration().arguments.size(); } size_t getNumberOfArguments() const override { return executable_function->getConfiguration().arguments.size(); }
bool useDefaultImplementationForConstants() const override { return true; } bool useDefaultImplementationForConstants() const override { return true; }
bool useDefaultImplementationForNulls() const override { return true; } bool useDefaultImplementationForNulls() const override { return false; }
bool isDeterministic() const override { return false; } bool isDeterministic() const override { return false; }
bool isDeterministicInScopeOfQuery() const override { return false; } bool isDeterministicInScopeOfQuery() const override { return false; }

View File

@ -289,4 +289,26 @@
<command>input_sum_json_named_args.py</command> <command>input_sum_json_named_args.py</command>
</function> </function>
<function>
<type>executable</type>
<name>test_function_nullable_python</name>
<return_type>String</return_type>
<argument>
<type>Nullable(UInt64)</type>
</argument>
<format>TabSeparated</format>
<command>input_nullable.py</command>
</function>
<function>
<type>executable</type>
<name>test_function_nullable_pool_python</name>
<return_type>String</return_type>
<argument>
<type>Nullable(UInt64)</type>
</argument>
<format>TabSeparated</format>
<command>input_nullable.py</command>
</function>
</functions> </functions>

View File

@ -228,3 +228,15 @@ def test_executable_function_sum_json_python(started_cluster):
) )
node.query("DROP TABLE test_table;") node.query("DROP TABLE test_table;")
def test_executable_function_input_nullable_python(started_cluster):
skip_test_msan(node)
node.query("CREATE TABLE test_table_nullable (value Nullable(UInt64)) ENGINE=TinyLog;")
node.query("INSERT INTO test_table_nullable VALUES (0), (NULL), (2);")
assert(node.query("SELECT test_function_nullable_python(1), test_function_nullable_python(NULL)") == "Key 1\tKey Nullable\n")
assert(node.query("SELECT test_function_nullable_python(value) FROM test_table_nullable;") == "Key 0\nKey Nullable\nKey 2\n")
assert(node.query("SELECT test_function_nullable_pool_python(1), test_function_nullable_pool_python(NULL)") == "Key 1\tKey Nullable\n")
assert(node.query("SELECT test_function_nullable_pool_python(value) FROM test_table_nullable;") == "Key 0\nKey Nullable\nKey 2\n")

View File

@ -0,0 +1,12 @@
#!/usr/bin/python3
import sys
if __name__ == "__main__":
for line in sys.stdin:
if (line == "\\N\n"):
print("Key Nullable", end="\n")
else:
print("Key " + line, end="")
sys.stdout.flush()