All Products
Search
Document Center

PolarDB:ST_ImportFrom

Last Updated:Oct 27, 2026

Imports a file from Object Storage Service (OSS), MinIO, or Hadoop Distributed File System (HDFS) into a database.

Syntax

raster ST_ImportFrom(cstring chunkTableName, 
                     cstring url, 
                     cstring storageOption default '{}',
                     cstring importOption default '{}');

Parameters

ParameterDescription
chunkTableNameThe name of the chunk table. The name must comply with the naming conventions of database tables.
urlThe path of the external file. For more information about how to construct the path, see ST_CreateRast.
storageOptionA JSON string that specifies the storage information of the raster object.
importOptionA JSON string that specifies the import options.

storageOption parameters are described as follows:

ParameterTypeDefault valueDescription
chunkingbooleantrue Specifies whether to use chunked storage.
chunkdimstringSame as the raw dataThe dimension information of the chunks. Format: (w, h, b).
Note This parameter takes effect only when chunking=true.
compressionstringlz4The type of the compression algorithm. Valid values:
  • none
  • jpeg
  • zlib
  • png
  • lzo
  • lz4
  • snappy
  • zstd
  • jp2k

Default: lz4

qualityinteger75The compression quality. This parameter takes effect only for the jpeg and jp2k compression algorithms.
interleavingstringSame as the raw dataThe interleaving method. Valid values:
  • bip: Band interleaved by pixel
  • bil: Band interleaved by line
  • bsq: Band Sequential
blockendianstring'NDR'The byte order of the chunk storage. Valid values:
  • NDR: little endian
  • XDR: big endian
celltypestringSame as the raw dataThe pixel type. Valid values:
  • 1bb: 1 bit
  • 2bui: 2-bit unsigned integer
  • 4bui: 4-bit unsigned integer
  • 8bsi: 8-bit signed integer
  • 8bui: 8-bit unsigned integer
  • 16bsi: 16-bit signed integer
  • 16bui: 16-bit unsigned integer
  • 32bsi: 32-bit signed integer
  • 32bui: 32-bit unsigned integer
  • 32bf: 32-bit float
  • 64bsi: 64-bit signed integer
  • 64bui: 64-bit unsigned integer
  • 64bf: 64-bit float
importOption parameters are described as follows.
ParameterTypeDefault valueDescription
mapping_oss_filebooleanfalseSpecifies whether to map the file on OSS to an in-memory file.
Note When raster data is read, some drivers are not optimized for the data stored in OSS. This generates many requests with a small data volume and results in low performance. This parameter maps the entire OSS file into an in-memory object to improve performance. The total file size is set by the GUC parameter ganos.raster.memory_oss_file_max_size.
parallelintegerThe value of the GUC parameter ganos.parallel.degree. Sets the degree of parallelism of the operation. Valid values: 1 to 64.

Description

The function creates a raster object and imports an external OSS file into the object.

To obtain the supported data types, call the ST_RasterDrivers function.

Examples

-- Specify only the foreign table name and the path
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif');

-- Specify the image that corresponds to a NetCDF file with a subset
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc');

-- Specify the chunk size and the compression type during the import
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.tif', '{"chunkdim":"(128,128,3)", "compression":"none"}');

-- Specify the degree of parallelism during the import
Select ST_ImportFrom('chunk_table','OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/data/image.nc:hcc', '{}', '{"parallel": 4}');