Import Parquet Data
PostgreSQL-compatible TiDB Cloud Starter supports the parquet extension for reading Parquet data and importing it into SQL tables.
This document describes Parquet access through HTTP or HTTPS URLs. The source URL must be reachable from TiDB Cloud.
Enable the parquet extension
Enable the extension in the target database:
CREATE EXTENSION IF NOT EXISTS parquet;
Query a Parquet file
Use the schema-qualified extensions.read_parquet() table function to query a Parquet file directly:
SELECT *
FROM extensions.read_parquet('https://example.com/data.parquet');
For example, to count rows:
SELECT count(*)
FROM extensions.read_parquet('https://example.com/data.parquet');
Import Parquet data into a table
Use COPY ... WITH (FORMAT parquet) to import Parquet data into an existing table.
For example:
CREATE TABLE users (
id BIGINT PRIMARY KEY,
name TEXT,
created_at TIMESTAMP
);
COPY users
FROM 'https://example.com/users.parquet'
WITH (FORMAT parquet);
Columns are matched by name case-insensitively.
- Parquet columns that do not have a matching target-table column are ignored.
- Target-table columns that do not have a matching Parquet column are filled with
NULL, subject to the target column constraints.
Type mapping
The following common Parquet types are mapped to PostgreSQL-compatible types:
Before importing data, verify that the Parquet schema is compatible with the target table schema.
Supported Parquet formats
The following Parquet formats are supported:
Limitations
The following limitations apply during the public preview:
- The target table must exist before you run
COPY ... WITH (FORMAT parquet). - Use an HTTP or HTTPS URL that is reachable from TiDB Cloud.
- Verify the Parquet column types before import. Some incompatible type combinations might not be rejected during import.
extensions.read_parquet()must be called with theextensionsschema qualifier.- Remote requests are subject to connection and request timeouts.