Skip to content

Latest commit

 

History

History
54 lines (44 loc) · 1.33 KB

File metadata and controls

54 lines (44 loc) · 1.33 KB
description
Converts a binary string from the given data type to a Spice type.

CONVERT_FROM

Syntax

CONVERT_FROM(binary_value value_to_convert, data_type name_of_type) → varies

  • binary_value: The binary string to convert to a Spice data type.
  • data_type: The data type of the specified binary string.

Examples

{% code title="Returns a LIST from the specified JSON." %}

SELECT CONVERT_FROM('["apple", "strawberry", "banana"]', 'json')
-- ['apple', 'strawberry', 'banana']

{% endcode %}

{% code title="Returns a STRUCT from the specified JSON." %}

SELECT CONVERT_FROM('{"name":"Gnarly", "age":7, "car":null}', 'json')
-- {"name:"Gnarly","age":7}

{% endcode %}

Usage Notes

You can convert from binary values that are in these data formats:

  • BIGINT_BE
  • BIGINT_HADOOPV
  • BIGINT
  • BOOLEAN_BYTE
  • DATE_EPOCH_BE
  • DATE_EPOCH
  • DOUBLE_BE
  • DOUBLE
  • FLOAT_BE
  • FLOAT
  • INT_BE
  • INT_HADOOPV
  • INT
  • JSON
  • TIME_EPOCH_BE
  • TIME_EPOCH
  • TIMESTAMP_EPOCH_BE
  • TIMESTAMP_EPOCH
  • TIMESTAMP_IMPALA_LOCALTIMEZONE
  • TIMESTAMP_IMPALA
  • UTF8