mirror of
https://github.com/asadbek064/hyparquet.git
synced 2026-01-03 10:26:36 +00:00
Parse metadata TimeUnit
This commit is contained in:
parent
9aebdb2917
commit
a56420de2f
@ -214,12 +214,12 @@ function logicalType(logicalType) {
|
||||
if (logicalType?.field_7) return {
|
||||
type: 'TIME',
|
||||
isAdjustedToUTC: logicalType.field_7.field_1,
|
||||
unit: logicalType.field_7.field_2,
|
||||
unit: timeUnit(logicalType.field_7.field_2),
|
||||
}
|
||||
if (logicalType?.field_8) return {
|
||||
type: 'TIMESTAMP',
|
||||
isAdjustedToUTC: logicalType.field_8.field_1,
|
||||
unit: logicalType.field_8.field_2,
|
||||
unit: timeUnit(logicalType.field_8.field_2),
|
||||
}
|
||||
if (logicalType?.field_10) return {
|
||||
type: 'INTEGER',
|
||||
@ -234,6 +234,16 @@ function logicalType(logicalType) {
|
||||
return logicalType
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} unit
|
||||
* @returns {import("./types.d.ts").TimeUnit | undefined}
|
||||
*/
|
||||
function timeUnit(unit) {
|
||||
if (unit.field_1) return 'MILLIS'
|
||||
if (unit.field_2) return 'MICROS'
|
||||
if (unit.field_3) return 'NANOS'
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert column statistics based on column type.
|
||||
*
|
||||
|
||||
2
src/types.d.ts
vendored
2
src/types.d.ts
vendored
@ -92,7 +92,7 @@ type LogicalDecimalType = {
|
||||
scale: number
|
||||
}
|
||||
|
||||
type TimeUnit = 'MILLIS' | 'MICROS' | 'NANOS'
|
||||
export type TimeUnit = 'MILLIS' | 'MICROS' | 'NANOS'
|
||||
|
||||
type LogicalTimeType = {
|
||||
type: 'TIME'
|
||||
|
||||
@ -12,9 +12,7 @@
|
||||
"logical_type": {
|
||||
"type": "TIMESTAMP",
|
||||
"isAdjustedToUTC": false,
|
||||
"unit": {
|
||||
"field_1": {}
|
||||
}
|
||||
"unit": "MILLIS"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user