Updated on 2026-11-06 GMT+08:00

Creating a Dataset

Syntax

CREATE [EXTERNAL] DATASET [IF NOT EXISTS] dataset_name 
[LOCATION location_path ]
[COMMENT comment ]
[SET (FORMAT <format> | FORMAT <format> CONTENT_TYPE (<content_type>*))]
  • EXTERNAL: Creates an external dataset. An external dataset must be registered to a directory within an external location. When EXTERNAL is not specified, the dataset type is MANAGED.
  • IF NOT EXISTS: If specified, no error is thrown when the dataset already exists.
  • dataset_name: Name of the dataset to be created. A dataset can only be created within a LakeFormation schema. A dataset must not have a naming conflict with other tables or datasets in the same database; otherwise, creation will fail.
  • LOCATION location_path: location_path is a string literal that defines the file system path for creating the specified external dataset. If the specified path does not exist in the underlying file system, a directory will be created at that path. A location must be specified when creating an external dataset. Managed datasets do not support location_path. The location of a managed dataset is automatically generated.
  • comment: Optional description of the dataset.
  • format: Data format enumeration: ROW/TEXT/IMAGE/AUDIO/VIDEO/CUSTOM.
  • content_type: When the format is ROW, optional values for content_type include: CSV (comma-separated values file), JSONL (JSON object lines file), and AVRO (AVRO row-based file).
    • For image file formats, this is set when the format is IMAGE. Optional values for content_type include: JPG (JPG image), PNG (PNG image), and TIFF (TIFF image).
    • content_type has no restrictions. Any string is allowed as content. format and content_type here serve as annotations to help users filter when listing datasets.

Sample Code

CREATE EXTERNAL DATASET my_catalog.my_schema.my_external_dataset LOCATION 'obs://my-bucket/my-location/my-path' COMMENT 'This is my example external dataset on OBS'
CREATE EXTERNAL DATASET my_catalog.my_schema.my_external_dataset LOCATION 'obs://my-bucket/my-location/my-path' COMMENT 'This is my example external dataset on OBS' SET FORMAT IMAGE CONTENT_TYPE ("JPG", "PNG")