* Fix #471 - Add UDF for extracting document type and version from wildcard tables
This commit is contained in:
Родитель
eaa38cf3c4
Коммит
7b5c00d3fd
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
|
||||
Extract the document type from a table name e.g. _TABLE_SUFFIX.
|
||||
|
||||
*/
|
||||
CREATE TEMP FUNCTION udf_extract_document_type(table_name STRING) AS (REGEXP_EXTRACT(table_name, r"^(.*)_v.*"));
|
||||
-- Tests
|
||||
SELECT
|
||||
assert_equals("type", udf_extract_document_type("type_v1")),
|
||||
assert_equals(
|
||||
"namespace__namespace_type",
|
||||
udf_extract_document_type("namespace__namespace_type_v20191031")
|
||||
);
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
|
||||
Extract the document version from a table name e.g. _TABLE_SUFFIX.
|
||||
|
||||
*/
|
||||
CREATE TEMP FUNCTION udf_extract_document_version(table_name STRING) AS (REGEXP_EXTRACT(table_name, r".*_v(.*)$"));
|
||||
-- Tests
|
||||
SELECT
|
||||
assert_equals("1", udf_extract_document_version("type_v1")),
|
||||
assert_equals(
|
||||
"20191031",
|
||||
udf_extract_document_version("namespace__namespace_type_v20191031")
|
||||
);
|
Загрузка…
Ссылка в новой задаче