diff --git a/opteryx/__version__.py b/opteryx/__version__.py index 091a7bc2..f2430b63 100644 --- a/opteryx/__version__.py +++ b/opteryx/__version__.py @@ -1,4 +1,4 @@ -__build__ = 741 +__build__ = 742 # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/opteryx/functions/__init__.py b/opteryx/functions/__init__.py index 792feb35..67e32dab 100644 --- a/opteryx/functions/__init__.py +++ b/opteryx/functions/__init__.py @@ -103,6 +103,12 @@ def cast_varchar(arr): return compute.cast(arr, "string") +def cast_blob(arr): + if len(arr) > 0 and all(i is None or type(i) == bytes for i in arr): + return arr + return compute.cast(arr, "binary") + + def fixed_value_function(function, context): from orso.types import OrsoTypes @@ -321,7 +327,7 @@ def select_values(boolean_arrays, value_arrays): "STR": cast_varchar, "STRUCT": _iterate_single_parameter(lambda x: orjson.loads(str(x)) if x is not None else None), "DATE": lambda x: compute.cast(x, pyarrow.date32()), - "BLOB": array_encode_utf8, + "BLOB": cast_blob, "TRY_TIMESTAMP": try_cast("TIMESTAMP"), "TRY_BOOLEAN": try_cast("BOOLEAN"), "TRY_NUMERIC": try_cast("DOUBLE"),