|
42 | 42 | # ln(2**(2**10)) == (2**10)*ln(2) ~= 709.78, so EXP(x) for x>709.78 will overflow. |
43 | 43 | _FLOAT64_EXP_BOUND = typing.cast(ibis_types.NumericValue, ibis_types.literal(709.78)) |
44 | 44 |
|
| 45 | +_OBJ_REF_STRUCT_SCHEMA = ( |
| 46 | + ("uri", ibis_dtypes.String), |
| 47 | + ("version", ibis_dtypes.String), |
| 48 | + ("authorizer", ibis_dtypes.String), |
| 49 | + ("details", ibis_dtypes.JSON), |
| 50 | +) |
| 51 | +_OBJ_REF_IBIS_DTYPE = ibis_dtypes.Struct.from_tuples(_OBJ_REF_STRUCT_SCHEMA) |
| 52 | + |
45 | 53 | # Datetime constants |
46 | 54 | UNIT_TO_US_CONVERSION_FACTORS = { |
47 | 55 | "W": 7 * 24 * 60 * 60 * 1000 * 1000, |
@@ -1161,6 +1169,12 @@ def json_extract_string_array_op_impl( |
1161 | 1169 | return json_extract_string_array(json_obj=x, json_path=op.json_path) |
1162 | 1170 |
|
1163 | 1171 |
|
| 1172 | +# Blob Ops |
| 1173 | +@scalar_op_compiler.register_unary_op(ops.obj_fetch_metadata_op) |
| 1174 | +def obj_fetch_metadata_op_impl(x: ibis_types.Value): |
| 1175 | + return obj_fetch_metadata(obj_ref=x) |
| 1176 | + |
| 1177 | + |
1164 | 1178 | ### Binary Ops |
1165 | 1179 | def short_circuit_nulls(type_override: typing.Optional[ibis_dtypes.DataType] = None): |
1166 | 1180 | """Wraps a binary operator to generate nulls of the expected type if either input is a null scalar.""" |
@@ -1832,3 +1846,8 @@ def json_extract_string_array( |
1832 | 1846 | @ibis.udf.scalar.builtin(name="ML.DISTANCE") |
1833 | 1847 | def vector_distance(vector1, vector2, type: str) -> ibis_dtypes.Float64: |
1834 | 1848 | """Computes the distance between two vectors using specified type ("EUCLIDEAN", "MANHATTAN", or "COSINE")""" |
| 1849 | + |
| 1850 | + |
| 1851 | +@ibis.udf.scalar.builtin(name="OBJ.FETCH_METADATA") |
| 1852 | +def obj_fetch_metadata(obj_ref: _OBJ_REF_IBIS_DTYPE) -> _OBJ_REF_IBIS_DTYPE: # type: ignore |
| 1853 | + """Fetch metadata from ObjectRef Struct.""" |
0 commit comments