I'm facing below error in CrateDB after upgrading Crate version 4.1.8 to 4.2.7
error during main processing: SQLActionException[UnsupportedFeatureException: Unknown function: to_object_array(db_name.tbl_name."object_array_type_col_name")]
error : {
"message": "SQLActionException[UnsupportedFeatureException: Unknown function: to_object_array(db_name.tbl_name."object_array_type_col_name")]",
"code": 4004
}
I'm trying to move data from one table to another using INSERT INTO with subsql query statement in CrateDB from existing table having column with data types OBJECT(DYNAMIC) and ARRAY(OBJECT(DYNAMIC)) and creating temp table with original schema of existing table.
As there is a column_policy = 'dynamic' at table level in original table, there are couple of columns added dynamically with same data types OBJECT(DYNAMIC) and ARRAY(OBJECT(DYNAMIC)).
Below is the full SQL query which I'm using to move the data which is working fine on Crate version 4.1.8 and raise above exception on version 4.2.7.
INSERT INTO temp_tbl (col1, col2_object, col3_object_array, col4, col5, dynamic_col6_object, dynamic_col6_object_array) (SELECT col1, to_object(col2_object), to_object_array(col3_object_array), col4, col5, to_object(dynamic_col6_object), to_object_array(dynamic_col6_object_array) FROM original_tbl);
UPDATE 1:
As mentioned/pointed by @proddata, I did try CAST but facing the below error
error: { "message": "SQLActionException[SQLParseException: The type 'object' of the insert source 'object_col_name' is not convertible to the type 'object' of target column 'object_col_name']", "code": 4000 }
to_object_array()is an internal / undocumented CrateDB function, which is hidden from 4.2 and upwardsCould you try to use
<column> :: <type>orcast(<column> AS <type>)instead.e.g.
also see https://crate.io/docs/crate/reference/en/4.6/general/ddl/data-types.html#cast
Edit: With some CrateDB version (probably ranging between 4.2.x - 4.5.1) there was a bug that prevented the
INSERTof objects from another table, if the object column in the target column has different object properties, that aren't a superset of the source object column. e.g.:More complete example ...
With version 4.2.7 the following query fails:
Tested with 4.2.7 (workaround for bug crate#11386
if columns already exist:
Tested with 4.6.3 (works)