You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "Shekharrajak (via GitHub)" <gi...@apache.org> on 2025/04/09 11:35:36 UTC

[I] Spark , Avro and Iceberg Timestamp , Timestamp NTZ definition need more clarifications [iceberg]

Shekharrajak opened a new issue, #12751:
URL: https://github.com/apache/iceberg/issues/12751

   * There is no definition added in spark for tiemstamp datatype variants : https://spark.apache.org/docs/3.5.0/sql-data-sources-avro.html#supported-types-for-spark-sql---avro-conversion
   * Avro spec : https://avro.apache.org/docs/1.12.0/specification/ 
   ```
   Timestamps
   The timestamp-{millis,micros,nanos} logical type represents an instant on the global timeline, independent of a particular time zone or calendar. Upon reading a value back, we can only reconstruct the instant, but not the original representation. In practice, such timestamps are typically displayed to users in their local time zones, therefore they may be displayed differently depending on the execution environment.
   
   timestamp-millis: logical type annotates an Avro long, where the long stores the number of milliseconds from the unix epoch, 1 January 1970 00:00:00.000.
   timestamp-micros: logical type annotates an Avro long, where the long stores the number of microseconds from the unix epoch, 1 January 1970 00:00:00.000000.
   timestamp-nanos: logical type annotates an Avro long, where the long stores the number of nanoseconds from the unix epoch, 1 January 1970 00:00:00.000000000.
   Example: Given an event at noon local time (12:00) on January 1, 2000, in Helsinki where the local time was two hours east of UTC (UTC+2). The timestamp is first shifted to UTC 2000-01-01T10:00:00 and that is then converted to Avro long 946720800000 (milliseconds) and written.
   
   Local Timestamps
   The local-timestamp-{millis,micros,nanos} logical type represents a timestamp in a local timezone, regardless of what specific time zone is considered local.
   
   local-timestamp-millis: logical type annotates an Avro long, where the long stores the number of milliseconds, from 1 January 1970 00:00:00.000.
   local-timestamp-micros: logical type annotates an Avro long, where the long stores the number of microseconds, from 1 January 1970 00:00:00.000000.
   local-timestamp-nanos: logical type annotates an Avro long, where the long stores the number of nanoseconds, from 1 January 1970 00:00:00.000000000.
   Example: Given an event at noon local time (12:00) on January 1, 2000, in Helsinki where the local time was two hours east of UTC (UTC+2). The timestamp is converted to Avro long 946728000000 (milliseconds) and then written.
   
   
   ```
   
   * Iceberg Spec for all the timestamp types :  https://iceberg.apache.org/spec/#avro
   ```
   
   timestamp | Timestamp, microsecond precision, without timezone
   
   timestamptz | Timestamp, microsecond precision, with timezone
   ```
   
   But spark 3 treat non timezone as TimestampNTZType but the avro serialiser will treat TimestampTZType as logicaltype timestamp-millis and TimestampNTZType as local-timestamp-millis 
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-3583618346

   This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "anesterenok (via GitHub)" <gi...@apache.org>.
anesterenok commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-2918703487

   > Is this an issue for Datafiles written with Avro Data instead of Parquet?
   Yes.  
   
   In Parquet, there's only one data type for timestamps (`TimestampType`), and whether its a local TS type or an instant type is specified by type attribute `isAdjustedToUTC `.
   
   In Avro, there are two type families, `timestamp-<unit>` for instants and `local-timestamp-<unit>` for local TS.  However, Iceberg incorrectly uses first one for both types.
   
   It is a bit strange because, say, when Iceberg writes ORC files, it does use appropriate ORC types (`timestamp` and `timestamp with local time zone`, in that case). 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-2916840926

   Is this an issue for Datafiles written with Avro Data instead of Parquet?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-3584397794

   >  spark 3 treat non timezone as TimestampNTZType but the avro serialiser will treat TimestampTZType as logicaltype timestamp-millis and TimestampNTZType as local-timestamp-millis
   
   I will start working on this. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "RussellSpitzer (via GitHub)" <gi...@apache.org>.
RussellSpitzer commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-2919990637

   Ok got it! We don't really have a lot of Avro data file users so I can see why this would have not come up that much. I think that's reasonable to fix though? Doesn't sound like a spec clarification, sounds like we just need to change the written logical type.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "anesterenok (via GitHub)" <gi...@apache.org>.
anesterenok commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-2921446275

   Oh, and since there's `timestamp_ns` now, the same goes for it: should be `local-timestamp-nanos`, not `timestamp-nanos`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-4550256145

   This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "anesterenok (via GitHub)" <gi...@apache.org>.
anesterenok commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-2918741426

   Maybe a table would be more helpful:
   
   | Iceberg type | File format | File format type                     | Correct?                             |
   |--------------|-------------|--------------------------------------|--------------------------------------|
   | timestamp    | Parquet     | TimestampType(isAdjustedToUTC=false) | yes                                  |
   | timestamp    | Avro        | timestamp-micros                     | no, should be local-timestamp-micros |
   | timestamp    | ORC         | timestamp                            | yes                                  |
   | timestamptz  | Parquet     | TimestampType(isAdjustedToUTC=true)  | yes                                  |
   | timestamptz  | Avro        | timestamp-micros                     | yes                                  |
   | timestamptz  | ORC         | timestamp with local time zone       | yes                                  |
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "anesterenok (via GitHub)" <gi...@apache.org>.
anesterenok commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-2921427738

   >  we just need to change the written logical type.
   
   Yes, I guess that's it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "anesterenok (via GitHub)" <gi...@apache.org>.
anesterenok commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-2916732246

   Iceberg convention to write local timestamps as Avro `timestamp-*` logical type is incorrect (does not conform to Avro spec).  No wonder other Avro clients like Spark can't read it correctly.
   
   There's a similar issue #11903.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [I] Spark, Avro and Iceberg Timestamp, Timestamp NTZ definition need more clarifications [iceberg]

Posted by "Shekharrajak (via GitHub)" <gi...@apache.org>.
Shekharrajak commented on issue #12751:
URL: https://github.com/apache/iceberg/issues/12751#issuecomment-4555937472

   @RussellSpitzer @anesterenok , please have a look https://github.com/apache/iceberg/pull/16577 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org