Collection Methods
This is a translation reference to convert the Oracle Collection Methods to Snowflake
This section is a work in progress, information may change in the future
Description
A collection method is a PL/SQL subprogram—either a function that returns information about a collection or a procedure that operates on a collection. Collection methods make collections easier to use and your applications easier to maintain.
Some of these methods can be mapped to native Snowflake semi-structured operations. The ones that can't or have differences will be mapped to a UDF implementation.
Current SnowConvert Support
The next table shows a summary of the current support provided by the SnowConvert tool. Please keep into account that translations may still not be final, and more work may be needed.
Sample Source Patterns
COUNT
This method returns the count of "non-undefined" (not to be confused with null) elements within a collection (nested tables can become sparse leaving these elements in between). In associative arrays, it returns the number of keys in the array.
Oracle
Snowflake
The snowflake equivalent is the ARRAY_SIZE method.
EXISTS
This method returns true if the given element is contained within the collection. In associative arrays, it tests if the key is contained.
Oracle
Snowflake
The snowflake equivalent is the ARRAY_CONTAINS method. Note that, when using Varchar elements, casting to Variant is necessary.
FIRST/LAST
These two methods return the First/Last element of the collection, respectively. If the collection is empty it returns null. This operation is mapped to a UDF, which will be added in further revisions.
Oracle
Snowflake
DELETE
This method is used to remove elements from a Collection. It has three possible variants:
.DELETE removes all elements.
.DELETE(n) removes the element whose index matches 'n'.
.DELETE(n, m) removes in the indexes from 'n' through 'm'.
Please note that the second and third versions do not apply to Varrays.
Oracle
For the sake of simplicity, this sample only checks on the number of elements but may be modified to display the contents of each collection.
Snowflake
Snowflake does not support deletions from an existing ARRAY and for this reason, the only offered workaround is to rebuild a new ARRAY depending on the original parameters of the DELETE.
EXTEND
This method is used to append new elements to a Nested Table or a Varray. It has three possible variants:
.EXTEND inserts a null element.
.EXTEND(n) inserts 'n' null elements.
.EXTEND(n, i) inserts 'n' copies of the element at 'i'.
Oracle
Snowflake
TRIM
This method is used to remove the last elements from a Nested Table or a Varray. It has two possible variants:
.TRIM removes the last element.
.TRIM(n) removes the last 'n' elements.
Oracle
LIMIT
This method returns the maximum limit of a Varray.
This method is not supported in Snowflake.
Oracle
PRIOR/NEXT
This method returns the prior/next index, given an index. If there is not a prior/next then it returns null. It is most frequently used to traverse a collection.
Oracle
Known Issues
1. Limit method is not supported in Snowflake
Snowflake does not have support for limited-space varrays. For this reason, this method is not supported.
Related EWIs
MSCEWI1058: Functionality is not currently supported by Snowflake Scripting.
Last updated
Was this helpful?