Knowledge Base

PARTITIONED_BY

NQL Clustering Metadata Reference

Overview

This reference provides a concise guide to using clustering metadata in NQL, including the function arguments, available options, and a brief example.

Function: PARTITIONED_BY

Arguments

  • field (string): The name of the column to use as the clustering key.
  • fn (string): The function applied to the clustering key. Options include:
    • IDENTITY: No transformation; the key is used as-is.
    • Other functions may be supported depending on the implementation.
  • args (array): Optional arguments passed to the function. For IDENTITY, this is an empty array.

What It Does

The PARTITIONED_BY clause specifies how data should be clustered in the resulting dataset. This improves query performance by organizing data based on the specified key.

Example

NQL Query

CREATE MATERIALIZED VIEW "clustered_sports_test" 
PARTITIONED_BY category IDENTITY AS
SELECT 
    first_name, 
    category 
FROM 
    company_data.sport_for_clustering;

Key Benefits

  • Improved Query Performance: Queries filtering on the clustering key are faster.
  • Cost Efficiency: Reduces the need for full table scans.

Notes

  • Ensure that the specified field exists in the dataset.
  • Use the NQL Editor to validate and test your queries before execution.
< Back
Rosetta

Hi! I’m Rosetta, your big data assistant. Ask me anything! If you want to talk to one of our wonderful human team members, let me know! I can schedule a call for you.