SUPER 구성 - Amazon Redshift

SUPER 구성

Amazon Redshift SUPER 데이터 형식 및 PartiQL을 사용할 때 SUPER 구성에 대한 다음 고려 사항에 유의합니다.

SUPER의 lax 및 strict 모드

SUPER 데이터를 쿼리할 때 경로 표현식이 실제 SUPER 데이터 구조와 일치하지 않을 수 있습니다. 존재하지 않는 객체 멤버 또는 배열 요소에 액세스하려고 할 때 쿼리가 기본 lax 모드에서 실행되는 경우 Amazon Redshift가 NULL 값을 반환합니다. strict 모드에서 쿼리를 실행하면 Amazon Redshift가 오류를 반환합니다. 다음 세션 파라미터를 설정하여 lax 모드를 설정하거나 해제할 수 있습니다.

다음 예에서는 세션 파라미터를 사용하여 lax 모드를 사용합니다.

SET navigate_super_null_on_error=ON; --default lax mode for navigation SET cast_super_null_on_error=ON; --default lax mode for casting SET parse_super_null_on_error=OFF; --default strict mode for ingestion

대문자 및 대소문자 혼합 필드 이름 또는 속성이 포함된 JSON 필드에 액세스

JSON 속성 이름이 대문자 또는 대소문자 혼합으로 되어 있는 경우 SUPER 유형 구조를 대소문자를 구분하는 방식으로 탐색할 수 있어야 합니다. 이렇게 하려면 enable_case_sensitive_identifier를 TRUE로 구성하고 대문자 및 대소문자 혼합 속성 이름을 큰따옴표로 묶습니다. enable_case_sensitive_super_attribute를 TRUE로 구성할 수도 있습니다. 이 경우 쿼리에 대문자 및 대소문자 혼합 속성 이름을 큰따옴표로 묶지 않고 사용할 수 있습니다.

다음 예에서는 데이터를 쿼리하도록 enable_case_sensitive_identifier를 설정하는 방법을 설명합니다.

SET enable_case_sensitive_identifier to TRUE; -- Accessing JSON attribute names with uppercase and mixedcase names SELECT json_table.data."ITEMS"."Name", json_table.data."price" FROM (SELECT json_parse('{"ITEMS":{"Name":"TV"}, "price": 345}') AS data) AS json_table; Name | price ------+------- "TV" | 345 (1 row) RESET enable_case_sensitive_identifier; -- After resetting the above configuration, the following query accessing JSON attribute names with uppercase and mixedcase names should return null (if in lax mode). SELECT json_table.data."ITEMS"."Name", json_table.data."price" FROM (SELECT json_parse('{"ITEMS":{"Name":"TV"}, "price": 345}') AS data) AS json_table; name | price ------+------- | 345 (1 row)

다음 예에서는 데이터를 쿼리하도록 enable_case_sensitive_super_attribute를 설정하는 방법을 설명합니다.

SET enable_case_sensitive_super_attribute to TRUE; -- Accessing JSON attribute names with uppercase and mixedcase names SELECT json_table.data.ITEMS.Name, json_table.data.price FROM (SELECT json_parse('{"ITEMS":{"Name":"TV"}, "price": 345}') AS data) AS json_table; name | price -----+------- "TV" | 345 (1 row) RESET enable_case_sensitive_super_attribute; -- After resetting enable_case_sensitive_super_attribute, the query now returns NULL for ITEMS.Name (if in lax mode). SELECT json_table.data.ITEMS.Name, json_table.data.price FROM (SELECT json_parse('{"ITEMS":{"Name":"TV"}, "price": 345}') AS data) AS json_table; name | price -----+------- | 345 (1 row)

SUPER에 대한 구문 분석 옵션

JSON_PARSE 함수를 사용하여 JSON 문자열을 SUPER 값으로 구문 분석하는 경우 특정 제한이 적용됩니다.

  • 동일한 속성 이름이 동일한 객체에 나타날 수는 없지만 중첩된 객체에는 나타날 수 있습니다. json_parse_dedup_attributes 구성 옵션을 사용하면 JSON_PARSE가 오류를 반환하는 대신 마지막으로 발생한 중복 속성만 유지할 수 있습니다.

  • 문자열 값은 시스템 최대 varchar 크기인 65535바이트를 초과할 수 없습니다. json_parse_truncate_strings 구성 옵션을 사용하면 JSON_PARSE()가 오류를 반환하지 않고 이 제한보다 긴 문자열을 자동으로 자를 수 있습니다. 이 동작은 문자열 값에만 영향을 주며 속성 이름에는 영향을 주지 않습니다.

JSON_PARSE 함수에 대한 자세한 내용은 JSON_PARSE 함수 섹션을 참조하세요.

다음 예에서는 json_parse_dedup_attributes 구성 옵션을 중복 속성에 대한 오류를 반환하는 기본 동작으로 설정하는 방법을 보여줍니다.

SET json_parse_dedup_attributes=OFF; --default behavior of returning error instead of de-duplicating attributes

다음 예에서는 json_parse_truncate_strings 구성 옵션을 이 제한보다 긴 문자열에 대해 오류를 반환하는 기본 동작으로 설정하는 방법을 보여줍니다.

SET json_parse_truncate_strings=OFF; --default behavior of returning error instead of truncating strings