Skip to content

[Subtask]: support parquet TIMESTAMP without timezone #22692

Closed

Description

@XuPeng-SH

Parent Issue

#22690

Detail of Subtask

support parquet TIMESTAMP without timezone

Describe implementation you've considered

No response

Additional information

No response

Activity

  1. added this to the MO-202510 milestone on Oct 28, 2025
  2. added theissue type on Oct 28, 2025
  3. added
    priority/p0
    on Oct 28, 2025
  4. Ariznawlll commented on Jan 26, 2026

    @Ariznawlll
    Collaborator
    测试脚本:
    
    import pandas as pd
    import pyarrow as pa
    import pyarrow.parquet as pq
    
    # 准备数据
    data = {
        'id': [1, 2, 3],
        # 模拟本地时间(不带时区)
        'ts_no_tz_micros': [
            pd.Timestamp('2023-10-27 10:00:00.123456'),
            pd.Timestamp('1960-01-01 12:00:00.000000'),
            None
        ],
        'ts_no_tz_millis': [
            pd.Timestamp('2025-12-25 08:30:00.123'),
            pd.Timestamp('2000-01-01 00:00:00.000'),
            pd.Timestamp('2023-12-31 23:59:59.999')
        ]
    }
    
    df = pd.DataFrame(data)
    
    # 定义 Schema,显式设置 is_adjusted_to_utc=False
    schema = pa.schema([
        pa.field('id', pa.int64()),
        # 指定单位为 microseconds (us) 或 milliseconds (ms),且不调整到 UTC
        pa.field('ts_no_tz_micros', pa.timestamp('us', tz=None), nullable=True),
        pa.field('ts_no_tz_millis', pa.timestamp('ms', tz=None), nullable=False)
    ])
    
    table = pa.Table.from_pandas(df, schema=schema)
    
    # 写入文件
    file_name = 'ts_no_tz_test.parquet'
    pq.write_table(table, file_name)
    
    # 验证元数据(可选,查看是否生成成功)
    meta = pq.read_metadata(file_name)
    print(f"Generated {file_name}")
    print(f"Schema logical type for column 1: {meta.schema.column(1).logical_type}")
    
    
    
    
    CREATE TABLE `ts_test` (
      `id` bigint DEFAULT NULL,
      `ts_no_tz_micros` datetime DEFAULT NULL,
      `ts_no_tz_millis` datetime DEFAULT NULL
    );
    
     load data infile {'filepath'='/Users/ariznawl/code/mo-nightly-regression/ts_no_tz_test.parquet', 'format'='parquet'} into table big_data_test.ts_test;
    
    
    
    
    Image

    测试通过✅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/subtaskpriority/p0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions