Band Join
Some parts in the output code are omitted for clarity reasons.
Description
A band join is a special type of nonequijoin in which key values in one data set must fall within the specified range (“band”) of the second data set. The same table can serve as both the first and second data sets. (Oracle SQL Language Reference BandJoin)
In this section, we will see how a band join is executed in Snowflake and the execution plan is very similar to the improved version of Oracle.
Sample Source Patterns
Order by clause added because the result order may vary between Oracle and Snowflake.
Since the result set is too large, Row Limiting Clause was added. You can remove it to retrieve the entire result set.
Check this section to set up the sample database.
If you migrate this code without the create tables, the converter won’t be able to load semantic information of the columns and a warning will appear on the arithmetic operations.
Basic Band Join case
Oracle
Snowflake
Migrating some SELECT
statements without the corresponding tables could generate the SSC-EWI-OR0036: Types resolution issues. To avoid this warning, include the CREATE TABLE
inside the file.
The results are the same making the BAND JOIN functional equivalent.
Execution plan
As extra information, the special thing about the band joins is the execution plan.
The following image shows the enhanced execution plan (implemented since Oracle 12c) for the test query:
And in the following image, we will see the execution plan in Snowflake:
The execution plan in Snowflake is very similar to Oracle’s optimized version. The final duration and performance of the query will be affected by many other factors and are completely dependent on each DBMS internal functionality.
Known Issues
1. Results ordering mismatch between languages
The query result will have the same content in both database engines but the order might be different if no Order By clause is defined in the query.
Related EWIs
SSC-EWI-OR0036: Types resolution issues, the arithmetic operation may not behave correctly between string and date.
Last updated