How should you complete the Apache Spark SQL code? To answer, select the appropriate options in the answer area.
NOTE: Each correct selection is worth one point.

Show answerHide answer
Explanation

Summary:
This question involves building a product dimension table by joining multiple source tables. The goal is to select the correct JOIN types and WHERE clause filters to create a clean, complete list of products, likely for a data warehouse. The logic must ensure we get all relevant products while handling potential missing relationships correctly.
Correct Option Explanations
1. First JOIN Type: LEFT OUTER JOIN
The product dimension must be based on all available products from the Products table (p). Using a LEFT OUTER JOIN to the ProductSubCategories table (s) ensures that every product is included in the result, even if it has a missing or invalid SubCategoryID. An INNER JOIN would incorrectly exclude any products without a valid subcategory.
2. Second JOIN Type: LEFT OUTER JOIN
The same logic applies for joining to the ProductCategories table (c). The join is performed from the already-outer-joined subcategory table. Using another LEFT OUTER JOIN guarantees that the final result includes all products from the first join, even if their corresponding subcategory has a missing or invalid link to a category.
3. WHERE Clause: IsActive = 1 AND ProductNumber is not null
IsActive = 1: A common business rule for a dimension is to only include currently active records. This filter selects only active products.
ProductNumber is not null: This is a data quality filter. A product key like ProductNumber should never be null in a well-formed dimension table. This ensures referential integrity and clean data.
The other options are incorrect:
Filtering on specific CategoryID or SubCategoryID values (e.g., = 1) is too restrictive.
Filtering on CategoryName is not null or SubCategoryName is not null would defeat the purpose of the outer joins, as it would remove the products with missing categories that we deliberately included.
Reference:
Microsoft Official Documentation: JOIN (Databricks SQL) - This explains the different join types available in Spark SQL, which is the engine used by Fabric.