All Products
Search
Document Center

PolarDB:ST_ImportObj

Last Updated:Mar 28, 2026

Imports an OBJ file from an Object Storage Service (OSS) bucket or a binary stream into a database.

Syntax

boolean ST_ImportObj(text table_name, text url,     text id, text options DEFAULT '{}');
boolean ST_ImportObj(text table_name, bytea content, text id, text options DEFAULT '{}');

The first overload loads the OBJ file from an OSS path. The second loads it from an in-memory binary stream. Both return true on success and false on failure.

Parameters

ParameterTypeDescription
table_nametextName of the OBJ primary table and the prefix for its sharded tables.
urltextOSS path to the OBJ file. Format: OSS://<ak>:<ak_secret>@<endpoint>/<bucket>/<path>.obj
contentbyteaOBJ file content as a binary stream.
idtextIdentifier assigned to the imported OBJ record.
optionstextJSON string of import options. Defaults to '{}'. See Import options.

Import options

Pass options as a JSON string, for example: '{"force_triangulate": false, "schema": "myschema"}'.

Options fall into two groups: storage configuration and import behavior.

Storage configuration

OptionTypeDefaultDescription
schemaStringpublicSchema of the target tables.
search_pathStringParent directory of the OBJ URL; empty when using binary contentPath used to locate material and texture files.
obj_id_columnStringobj_idName of the data ID field in the primary table.
obj_data_columnStringobj_dataName of the data field in the primary table.

Import behavior

OptionTypeDefaultDescription
ignore_missingBooleantrueWhen true, missing material or texture files are silently skipped. Set to false to abort the import if any referenced material or texture file cannot be found.
force_triangulateBooleantrueWhen true, non-triangular faces are automatically converted to triangles. Set to false to import non-triangular faces as-is.
metallic_roughnessBooleantrueWhen true, materials are parsed as the metallic_roughness PBR type. Set to false to parse materials as the specular-glossiness type instead.

Limitations

Only textures of the diffusetexture type are supported. Textures of other types are ignored during import.

Table schemas

ST_ImportObj creates or populates three tables: a primary table, a component table, and a texture table.

Primary table

FieldTypeDescription
idserialPrimary key.
[obj_id_column]textOBJ record identifier. The field name defaults to obj_id and can be changed with the obj_id_column option.
[obj_data_column]sfmeshMesh data. The field name defaults to obj_data and can be changed with the obj_data_column option.

Component table

FieldTypeDescription
idserialPrimary key.
obj_idtextOBJ record identifier. Fixed field name.
component_idtextSequence number of the component within the original OBJ file.
nametextComponent name. Derived from the g (group) or o (object) directive in the OBJ file. If multiple names exist, the first is used. Defaults to Mesh_[object sequence number] when no name is defined.
tagsjsonbTags associated with the component.
componentsfmeshComponent mesh data.

Texture table

FieldTypeDescription
idserialPrimary key.
obj_idtextOBJ record identifier. Fixed field name.
texture_idtextSequence number of the texture within the original OBJ file.
nametextFile name of the texture.
texturetextureTexture data.

Examples

Basic import from OSS

SELECT ST_ImportObj('test_obj', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_obj.obj');
---------
t

Disable forced triangulation

By default, non-triangular faces are converted to triangles. To preserve the original face topology:

SELECT ST_ImportObj('test_obj', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_obj.obj', '{"force_triangulate": false}');

Specify a texture search path

When textures are stored in a different OSS directory from the OBJ file, set search_path to point to that directory:

SELECT ST_ImportObj('test_obj', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/models/scene.obj', '{"search_path": "OSS://foo/bar"}');

Import with a custom schema and column names

SELECT ST_ImportObj('test_obj', 'OSS://<ak>:<ak_secret>@oss-cn-beijing-internal.aliyuncs.com/mybucket/path_to_obj.obj', '{"schema": "gis", "obj_id_column": "model_id", "obj_data_column": "mesh_data"}');