Looking to create a table and include a calculated column that references a javascript function. I have found that I can do calculations in the calculated column using as case statement.
but I created the following function, cant seem to get it to work with the calculated column. Do you know if this is functionality I am just using wrong or not currently supported?
create or replace function UTILITY.function.JSON_TO_TABLE_SOURCE_COLUMN_TEXT_test
(COLUMN_NAME_PREFIX varchar, COLUMN_NAME varchar)
returns varchar
language javascript
AS $$
return COLUMN_NAME_PREFIX + ':' + COLUMN_NAME
$$
;
CREATE OR REPLACE TABLE DEV_BCOLEMAN.dev.T2(
SOURCE_COLUMN_NAME varchar,
SOURCE_COLUMN_PREFIX varchar,
SOURCE_COLUMN_TEXT varchar(100) AS (UTILITY.function.JSON_TO_TABLE_SOURCE_COLUMN_TEXT_TEST(SOURCE_COLUMN_PREFIX, SOURCE_COLUMN_NAME))
);
Hoping the output would look something like this:
| SOURCE_COLUMN_NAME | SOURCE_COLUMN_PREFIX | SOURCE_COLUMN_TEXT |
|---|---|---|
| id | data | data:id |
Couple of the ways I tried:
SOURCE_COLUMN_TEXT varchar(100) as UTILITY.FUNCTION.JSON_TO_TABLE_SOURCE_COLUMN_TEXT('data','id')
SOURCE_COLUMN_TEXT varchar(100) as (select UTILITY.FUNCTION.JSON_TO_TABLE_SOURCE_COLUMN_TEXT('data', 'id')
The error is:: Invalid virtual column expression [JSON_TO_TABLE_SOURCE_COLUMN_TEXT..]
