IS EMPTY
This is a translation reference to convert the Oracle IS EMPTY statement to Snowflake
This section is a work in progress; information may change in the future.
Description
Use the IS [NOT] EMPTY conditions to test whether a specified nested table is empty, regardless whether any elements of the collection are NULL. (Documentation).
Oracle syntax
Sample Source Patterns
Oracle
The following example shows the usage of the IS EMPTY statement. The statement is applied over a nested table which uses a UDT as the definition type. The output shows the name of the employees who do not have a phone number.
Snowflake
The Snowflake query shown below is the equivalence of the functionality of the IS EMPTY statement. Particularly, the IS EMPTY statement has a difference between a NULL and an EMPTY object.
Notice that the User-Defined Types are transformed to a VARIANT. The VARIANT type in Snowflake is able to store objects and arrays. Since a nested table is a sequence of information, the ARRAY type is the most suitable type to redefine them and verify is the object ARRAY is empty.
The ARRAY_SIZE equivalent solution also allows to ask for nullability of the nested table (transformed to VARIANT). In other words, the VARIANT type can also store NULLs and empty ARRAYs.
Other possible combinations
Description | Oracle | Snowflake |
---|---|---|
Ask for a IS NOT EMPTY | ||
Ask for NULL instead of EMPTY |
Known Issues
1. User-defined types are being transformed into Variant.
User-defined types are not supported thus they are transformed into Variant types which could need manual effort to ensure some functionalities.
Review the following page for more information:
Create Type2. Nested tables are not supported.
Nested tables are not currently supported. The best approach based on this equivalence is to handle nested tables as Variant but declare Arrays with JSON data inside and execute the PARSE_JSON Snowflake function to populate the nested information.
Review the following pages for more information:
Nested Table Array Type DefinitionNested Table Type Definition3. Insert statements are not supported for User-defined types.
Since User-defined types are not supported in consequence the Insert statements to these types are not supported. Specifically in nested tables, the INSERT INTO ... VALUES
statement has to be changed to a INSERT INTO ...SELECT
because the ARRAY_CONSTRUCT function is expected to be used in that pattern.
Review the following page for more information:
Object Type Definition4. Logic should be adapted to ARRAY
types.
ARRAY
types.Since the nested tables should be equivalently transformed to VARIANT
and behave as ARRAYs,
the functionality and logic of implementing procedures and interaction with the data should be adapted.
Review the following examples:
4.1 Procedures equivalence
4.2 Select statements
Outputs may differ from tables to ARRAYs
.
Oracle
Snowflake
Related EWIs
Last updated