This topic shows the different ways to export query results to Parquet files.
This topic contains the following sections:
-
Review the following:
Use the following SELECT INTO
JSON syntax to export the query results into a Parquet file.
SELECT ... INTO OUTFILE WITH PARAMETERS
'file_URI_JSON "file":
begin-array ("uri": "OCIFS_URI") | ("uri": "PAR_URI") | ("uri": "NATIVE_URI"),
[, "dialect": begin-object dialect_option [, dialect_option]... end-object ]
end-object'
'begin-object_PAR_JSON "file":
begin-array "par": "par_url" [, "prefix": "prefix_value" ] end-array
[,"dialect": begin-object dialect_option [, dialect_option]... end-object ]
end-object'
'begin-object_RP_JSON "file":
begin-array "bucket": "bucket_name" [, "prefix": "prefix_value" [, "namespace: "namespace_name" ] [,"region": "region_name" ] ] end-array
[,"dialect": begin-object dialect_option [, dialect_option]... end-object ]
end-object'
dialect_option:
{
{"format": "parquet" }
| {"compression": {"uncompressed" | "snappy" | "gzip" | "brotli" | "zstd" | "lz4"} }
}
Supported as of MySQL 9.3.1. The following parameters are included in the JSON syntax to export the query results to the Object Storage location represented as a URI.
-
URI
: The Object Storage location is represented as a URI link. The URI must be a prefix URI and end in an unencoded/
character.You can specify the following types of URIs.
-
OCIFS Syntax:
oci://bucket_name@namespace_name/object_path
Example:
oci://bucket_1@tenant_1/data_files/
-
PAR URI Syntax. You can use one of the following formats:
https://namespace_name.objectstorage.region_name.oci.customer-oci.com/p/PAR_token/n/namespace_name/b/bucket_name/o/object_path
https://objectstorage.region_name.oraclecloud.com/p/PAR_token/n/namespace_name/b/bucket_name/o/object_path
Example:
https://tenant_1.objectstorage.us-ashburn-1.oci.customer-oci.com/p/.../n/tenant_1/b/bucket_1/o/data_files/
-
Native URI Syntax. You can use one of the following formats:
https://namespace_name.objectstorage.region_name.oci.customer-oci.com/n/namespace_name/b/bucket_name/o/object_path
https://objectstorage.region_name.oraclecloud.com/n/namespace_name/b/bucket_name/o/object_path
Example:
https://tenant_1.objectstorage.us-ashburn-1.oci.customer-oci.com/n/tenant_1/b/bucket_1/o/data_files/
-
dialect
: The dialect parameters assist you to organize the data in the exportedCSV
file.
The following parameters are included in the JSON syntax to export the query results to the Object Storage location represented as a PAR URL.
-
URL
: You can use a PAR URL to access Object Storage. Learn more about Pre-Authenticated Request Requirements to export query results. To learn more about PARs, see Object Storage Pre-Authenticated Requests in Oracle Cloud Infrastructure Documentation.For security reasons, the PAR URL is hidden in the log file. For more information and samples, see Redacted PAR URLs in Exported Log Files.
format
: The file format to export the query results. Export the query results as aCSV
,Parquet
, orJSON
(As of MySQL 9.3.1) file. By default, the results are exported to aCSV
file.compression
: The file compression type for CSV format. The supported compression types areuncompressed
,snappy
,gzip
,brotli
,zstd
andlz4
(as supported by the Lakehouse load).
The following parameters are included in the JSON syntax to export the query results to the Object Storage location based on the assigned resource principal.
format
: The file format to export the query results. Export the query results as aCSV
,Parquet
, orJSON
(As of MySQL 9.3.1) file. By default, the results are exported to aCSV
file.bucket
: The bucket name.prefix
: The directory located within the bucket to store the export query results. This is an optional parameter.namespace
: The tenancy namespace.region
: The region that the tenancy is in.compression
: he file compression type for CSV format. The supported compression types areuncompressed
,snappy
,gzip
,brotli
,zstd
andlz4
(as supported by the Lakehouse load).
The following example uses a specified OCIFS URI to export
the query results as a Parquet
file.
SELECT sum(l_quantity) from lineitem limit 1000
INTO OUTFILE WITH PARAMETERS
'{"file":[{
"uri":"oci://bucket_1@tenancy1/data_files_1/"}],
"dialect":
{"format": "parquet"
}
}';
The following example uses a specified PAR URL to export the
query results as a Parquet
file.
SELECT sum(l_quantity) from lineitem limit 1000
INTO OUTFILE WITH PARAMETERS
'{"file":[{
"par":"https://objectstorage.region1.oraclecloud.com/p/PTn9XsVegDBbSz1v-FgDma4G_e_78fJjv1GK04zlSqD9975MPZydieUJAGUypxQb/n/tenancy1/b/usr-bucket/o/", "prefix":"summary/2025"}],
"dialect":
{"format": "parquet"
}
}';
The following example uses resource principals to export the
query results as a parquet
file. This
sample uses the default values, dialect parameters are not
required.
mysql>SELECT sum(l_quantity) from lineitem limit 1000
INTO OUTFILE WITH PARAMETERS
'{"file":[{"region": region1,
"namespace": org_namespace,
"bucket": usr-bucket,
"prefix": export/summary/
"dialect": {"format": "parquet"}
}]
}';
The following example sets the compression to
snappy
.
mysql> SELECT sum(l_quantity) from lineitem limit 1000
INTO OUTFILE WITH PARAMETERS
'{"file":[{"region": "region1",
"namespace": "org_namespace",
"bucket": "usr-bucket",
"prefix": "prefix1/prefix2/"
}]
"dialect": {"compression": "snappy", "format": "parquet"}
}';
-
Review the following: