Re: [Discussion] Follow up discussion for Interval Type

2025-07-14 Thread yun zou
> I don't think it is critical to add seconds. But I do think we should
consider
> current engine compatibility. Supporting at least microseconds would add
> value as I think most existing OSS engines support this range (engines
> would not need to scale to/from their native resolution).

Make sense. As for implementation, I think we can start with nano-seconds to
understand the complexity first.

> I think starting with int64 still makes sense here.  It will likely
satisfy
> most use-cases, and in general will be easier for existing OSS engines to
> integrate with.

Sure, I think we can definitely start with int64.

Based on the above discussion, it appears that we're making a small
adjustment to the plan:
1. Instead of introducing NanoDuration, we will introduce a more general
Duration type
that takes TimeUnit as a parameter and annotates int64, starting with
support for nanoseconds.
2. The YearMonthInterval type remains the same, and it annotates int32.

We will continue evaluating int128 versus FLAB(16), and once a decision is
made,
we will proceed with expanding the range of the existing time-related types.

Best Regards,
Yun

On Fri, Jul 11, 2025 at 12:22 PM Micah Kornfield 
wrote:

> Hi Yun,
>
> After thinking about it some, here are my thoughts.
>
>
> > Introducing parameterization would definitely add complexity and increase
> > the number of logical types. Also, Parquet currently doesn’t support
> > seconds
> > as a time unit.  Given that, it might be more practical to start with a
> > concrete type
> > like NanoDuration, and add other *Unit*Duration types later if needed.
>
>
> I think the main issue being raised is this would make it inconsistent with
> Timestamp logical annotations.  I don't think it is critical to add
> seconds. But I do think we should consider current engine compatibility.
> Supporting at least microseconds would add value as I think most existing
> OSS engines support this range (engines would not need to scale to/from
> their native resolution).  We can defer making a final decision on what
> resolutions will actually need to be supported until we look at the
> additional complexity in implementations.
>
>
> f that’s the direction, should we define NanoDuration directly using the
> > widest size—FLAB(16)—or
> > annotate support for both int64 and FLAB(16)? My inclination is to go
> with
> > the wider type from the start
> > to keep things simpler, but I’d love to hear others’ thoughts on this.
>
>
> I think starting with int64 still makes sense here.  It will likely satisfy
> most use-cases, and in general will be easier for existing OSS engines to
> integrate with. I responded on the FLBA vs int128 thread but I think we
> still need to do some code exploration to understand the true trade-offs
> here.  I think decoupling from the wider type discussion would allow us to
> get this done sooner.
>
> Cheers,
> Micah
>
>
>
>
> On Fri, Jul 11, 2025 at 11:44 AM yun zou 
> wrote:
>
> > > The Arrow format supports 64-bit durations of seconds, milliseconds,
> > > microseconds and nanoseconds. It would make sense for Parquet to
> > > roundtrip these types IMHO.
> >
> > Introducing parameterization would definitely add complexity and increase
> > the number of logical types. Also, Parquet currently doesn’t support
> > seconds
> > as a time unit.  Given that, it might be more practical to start with a
> > concrete type
> > like NanoDuration, and add other *Unit*Duration types later if needed.
> >
> > Following up on the related discussion about int128 vs FLAB(16)(see:
> > https://lists.apache.org/thread/7zfwc3o53btd2xbdb8bqf8lxsrk76cxr),
> > it seems there’s a general preference for sticking with FLAB(16) rather
> > than introducing
> > a new int128 type.
> >
> > If that’s the direction, should we define NanoDuration directly using the
> > widest size—FLAB(16)—or
> > annotate support for both int64 and FLAB(16)? My inclination is to go
> with
> > the wider type from the start
> > to keep things simpler, but I’d love to hear others’ thoughts on this.
> >
> > Best Regards,
> > Yun Zou
> >
> > On Fri, Jul 11, 2025 at 9:23 AM Antoine Pitrou 
> wrote:
> >
> > > On Thu, 10 Jul 2025 17:18:34 -0700
> > > yun zou 
> > > wrote:
> > > > > I think the point was raised previously that hard-coded names were
> > > > > preferred but I don't recall if that was when we were still calling
> > > this
> > > > > DayTime?
> > > >
> > > > I believe the main concern around naming is focused on whether to
> > > > use *"Duration"* or *"Interval"*, rather than the inclusion of
> *"Nano"*
> > > in
> > > > the type name.
> > > >
> > > > As for the parameterized time unit, the primary issue seems to be
> that
> > > > the *physical type size would vary depending on the unit* — for
> > example,
> > > > using int32 for milliseconds and int64 for microseconds. However, it
> > > sounds
> > > > like the proposal is to use the same physical type, the unit is just
> > > used to
> > > > indicate the type name.
> > >
> 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-11 Thread Micah Kornfield
Hi Yun,

After thinking about it some, here are my thoughts.


> Introducing parameterization would definitely add complexity and increase
> the number of logical types. Also, Parquet currently doesn’t support
> seconds
> as a time unit.  Given that, it might be more practical to start with a
> concrete type
> like NanoDuration, and add other *Unit*Duration types later if needed.


I think the main issue being raised is this would make it inconsistent with
Timestamp logical annotations.  I don't think it is critical to add
seconds. But I do think we should consider current engine compatibility.
Supporting at least microseconds would add value as I think most existing
OSS engines support this range (engines would not need to scale to/from
their native resolution).  We can defer making a final decision on what
resolutions will actually need to be supported until we look at the
additional complexity in implementations.


f that’s the direction, should we define NanoDuration directly using the
> widest size—FLAB(16)—or
> annotate support for both int64 and FLAB(16)? My inclination is to go with
> the wider type from the start
> to keep things simpler, but I’d love to hear others’ thoughts on this.


I think starting with int64 still makes sense here.  It will likely satisfy
most use-cases, and in general will be easier for existing OSS engines to
integrate with. I responded on the FLBA vs int128 thread but I think we
still need to do some code exploration to understand the true trade-offs
here.  I think decoupling from the wider type discussion would allow us to
get this done sooner.

Cheers,
Micah




On Fri, Jul 11, 2025 at 11:44 AM yun zou  wrote:

> > The Arrow format supports 64-bit durations of seconds, milliseconds,
> > microseconds and nanoseconds. It would make sense for Parquet to
> > roundtrip these types IMHO.
>
> Introducing parameterization would definitely add complexity and increase
> the number of logical types. Also, Parquet currently doesn’t support
> seconds
> as a time unit.  Given that, it might be more practical to start with a
> concrete type
> like NanoDuration, and add other *Unit*Duration types later if needed.
>
> Following up on the related discussion about int128 vs FLAB(16)(see:
> https://lists.apache.org/thread/7zfwc3o53btd2xbdb8bqf8lxsrk76cxr),
> it seems there’s a general preference for sticking with FLAB(16) rather
> than introducing
> a new int128 type.
>
> If that’s the direction, should we define NanoDuration directly using the
> widest size—FLAB(16)—or
> annotate support for both int64 and FLAB(16)? My inclination is to go with
> the wider type from the start
> to keep things simpler, but I’d love to hear others’ thoughts on this.
>
> Best Regards,
> Yun Zou
>
> On Fri, Jul 11, 2025 at 9:23 AM Antoine Pitrou  wrote:
>
> > On Thu, 10 Jul 2025 17:18:34 -0700
> > yun zou 
> > wrote:
> > > > I think the point was raised previously that hard-coded names were
> > > > preferred but I don't recall if that was when we were still calling
> > this
> > > > DayTime?
> > >
> > > I believe the main concern around naming is focused on whether to
> > > use *"Duration"* or *"Interval"*, rather than the inclusion of *"Nano"*
> > in
> > > the type name.
> > >
> > > As for the parameterized time unit, the primary issue seems to be that
> > > the *physical type size would vary depending on the unit* — for
> example,
> > > using int32 for milliseconds and int64 for microseconds. However, it
> > sounds
> > > like the proposal is to use the same physical type, the unit is just
> > used to
> > > indicate the type name.
> >
> > Certainly the latter, IMHO.
> >
> > > > I do think it's reasonable to parameterize `TimeUnit`
> > > > for consistency and future proofing but for now we should say it only
> > > > supports Nanoseconds
> > >
> > > It feels a bit odd to introduce a parameter when it currently only
> > supports
> > > a single value.
> > > An alternative could be to start with a concrete type like
> > *NanoDuration*,
> > > and if future
> > > requirements arise, we can consider adding new logical types such as
> > > *MicroDuration*, etc.
> > > The disadvantage is that the number of logical type definitions will
> > > increase along with the units
> > > we want to support, but I doubt there will be a lot.
> >
> > The Arrow format supports 64-bit durations of seconds, milliseconds,
> > microseconds and nanoseconds. It would make sense for Parquet to
> > roundtrip these types IMHO.
> >
> > Regards
> >
> > Antoine.
> >
> >
> >
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-11 Thread yun zou
> The Arrow format supports 64-bit durations of seconds, milliseconds,
> microseconds and nanoseconds. It would make sense for Parquet to
> roundtrip these types IMHO.

Introducing parameterization would definitely add complexity and increase
the number of logical types. Also, Parquet currently doesn’t support seconds
as a time unit.  Given that, it might be more practical to start with a
concrete type
like NanoDuration, and add other *Unit*Duration types later if needed.

Following up on the related discussion about int128 vs FLAB(16)(see:
https://lists.apache.org/thread/7zfwc3o53btd2xbdb8bqf8lxsrk76cxr),
it seems there’s a general preference for sticking with FLAB(16) rather
than introducing
a new int128 type.

If that’s the direction, should we define NanoDuration directly using the
widest size—FLAB(16)—or
annotate support for both int64 and FLAB(16)? My inclination is to go with
the wider type from the start
to keep things simpler, but I’d love to hear others’ thoughts on this.

Best Regards,
Yun Zou

On Fri, Jul 11, 2025 at 9:23 AM Antoine Pitrou  wrote:

> On Thu, 10 Jul 2025 17:18:34 -0700
> yun zou 
> wrote:
> > > I think the point was raised previously that hard-coded names were
> > > preferred but I don't recall if that was when we were still calling
> this
> > > DayTime?
> >
> > I believe the main concern around naming is focused on whether to
> > use *"Duration"* or *"Interval"*, rather than the inclusion of *"Nano"*
> in
> > the type name.
> >
> > As for the parameterized time unit, the primary issue seems to be that
> > the *physical type size would vary depending on the unit* — for example,
> > using int32 for milliseconds and int64 for microseconds. However, it
> sounds
> > like the proposal is to use the same physical type, the unit is just
> used to
> > indicate the type name.
>
> Certainly the latter, IMHO.
>
> > > I do think it's reasonable to parameterize `TimeUnit`
> > > for consistency and future proofing but for now we should say it only
> > > supports Nanoseconds
> >
> > It feels a bit odd to introduce a parameter when it currently only
> supports
> > a single value.
> > An alternative could be to start with a concrete type like
> *NanoDuration*,
> > and if future
> > requirements arise, we can consider adding new logical types such as
> > *MicroDuration*, etc.
> > The disadvantage is that the number of logical type definitions will
> > increase along with the units
> > we want to support, but I doubt there will be a lot.
>
> The Arrow format supports 64-bit durations of seconds, milliseconds,
> microseconds and nanoseconds. It would make sense for Parquet to
> roundtrip these types IMHO.
>
> Regards
>
> Antoine.
>
>
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-11 Thread Antoine Pitrou
On Thu, 10 Jul 2025 17:18:34 -0700
yun zou 
wrote:
> > I think the point was raised previously that hard-coded names were
> > preferred but I don't recall if that was when we were still calling this
> > DayTime?  
> 
> I believe the main concern around naming is focused on whether to
> use *"Duration"* or *"Interval"*, rather than the inclusion of *"Nano"* in
> the type name.
> 
> As for the parameterized time unit, the primary issue seems to be that
> the *physical type size would vary depending on the unit* — for example,
> using int32 for milliseconds and int64 for microseconds. However, it sounds
> like the proposal is to use the same physical type, the unit is just used to
> indicate the type name.

Certainly the latter, IMHO.

> > I do think it's reasonable to parameterize `TimeUnit`
> > for consistency and future proofing but for now we should say it only
> > supports Nanoseconds  
> 
> It feels a bit odd to introduce a parameter when it currently only supports
> a single value.
> An alternative could be to start with a concrete type like *NanoDuration*,
> and if future
> requirements arise, we can consider adding new logical types such as
> *MicroDuration*, etc.
> The disadvantage is that the number of logical type definitions will
> increase along with the units
> we want to support, but I doubt there will be a lot.

The Arrow format supports 64-bit durations of seconds, milliseconds,
microseconds and nanoseconds. It would make sense for Parquet to
roundtrip these types IMHO.

Regards

Antoine.




Re: [Discussion] Follow up discussion for Interval Type

2025-07-10 Thread yun zou
> I think the point was raised previously that hard-coded names were
> preferred but I don't recall if that was when we were still calling this
> DayTime?

I believe the main concern around naming is focused on whether to
use *"Duration"* or *"Interval"*, rather than the inclusion of *"Nano"* in
the type name.

As for the parameterized time unit, the primary issue seems to be that
the *physical type size would vary depending on the unit* — for example,
using int32 for milliseconds and int64 for microseconds. However, it sounds
like the proposal is to use the same physical type, the unit is just used to
indicate the type name.

> I do think it's reasonable to parameterize `TimeUnit`
> for consistency and future proofing but for now we should say it only
> supports Nanoseconds

It feels a bit odd to introduce a parameter when it currently only supports
a single value.
An alternative could be to start with a concrete type like *NanoDuration*,
and if future
requirements arise, we can consider adding new logical types such as
*MicroDuration*, etc.
The disadvantage is that the number of logical type definitions will
increase along with the units
we want to support, but I doubt there will be a lot.

Furthermore,  once we are settled on the discussion for int128 or FLAB(16),
we should be able to cover the full value range with a single
representation without any
parameterization.  Given that, will we still need a parameterized
representation? Alternatively,
we could go with NanoDuration for now, and once there's a decision to adopt
int128 or FLAB(16),
we can focus on expanding the range at that point ?

Best Regards,
Yun



On Thu, Jul 10, 2025 at 12:27 PM Ryan Blue  wrote:

> I think it would be fine to have an int64 with a duration logical type
> parameterized by unit. That fits with the timestamp types that we have
> defined, which are also parameterized by unit. Iceberg is going to be more
> strict about what can be produced, but this is probably a good idea for
> Parquet.
>
> On Thu, Jul 10, 2025 at 10:38 AM Micah Kornfield 
> wrote:
>
> > >
> > > Quick question: is there a good reason not to just have a logical
> > Duration
> > > that annotates an int64 and let the unit be parameterized instead of
> hard
> > > coding it to be nanoseconds?
> >
> >
> > It adds additional effort/complexity for engines to consider each unit
> > (perhaps minimal)? I do think it's reasonable to parameterize `TimeUnit`
> > for consistency and future proofing but for now we should say it only
> > supports Nanoseconds (unless someone is signing up to support the other
> > units in the implementation).
> >
> > I think the point was raised previously that hard-coded names were
> > preferred but I don't recall if that was when we were still calling this
> > DayTime?
> >
> > Cheers,
> > Micah
> >
> > On Thu, Jul 10, 2025 at 9:58 AM Matt Topol 
> wrote:
> >
> > > Quick question: is there a good reason not to just have a logical
> > Duration
> > > that annotates an int64 and let the unit be parameterized instead of
> hard
> > > coding it to be nanoseconds?
> > >
> > > That would at least allow the full 10k years for other units, and allow
> > > better compression if nanosecond precision isn't needed.
> > >
> > > Thoughts?
> > >
> > > On Wed, Jul 9, 2025, 11:02 AM Micah Kornfield 
> > > wrote:
> > >
> > > > OK to summarize what I think the current proposal for interval type
> is
> > > two
> > > > new logical types:
> > > >
> > > > 1.  YearMonth interval annotates an int32.
> > > > 2.  DurationNanos annotates an int64.
> > > >
> > > > There is now a separate thread, on int128 vs FLBA. Given the current
> > > > proposal I don't think this blocks anything.  The main difficulty in
> > > adding
> > > > a newly annotated physical type would be API design allowing a
> > > potentially
> > > > wider type in the future.  I think this is tractable but any blockers
> > > could
> > > > be discovered in the implementation phase?
> > > >
> > > > > +1 to FLBA and VLBA. What would BIT represent? Could you elaborate
> > > >
> > > > I think the intent would be boolean.
> > > >
> > > > On Wednesday, July 9, 2025, Alkis Evlogimenos
> > > >  wrote:
> > > >
> > > > > On Wed, Jul 9, 2025 at 11:05 AM Antoine Pitrou  >
> > > > wrote:
> > > > >
> > > > > > But if we were designing a new Parquet format from scratch, I
> would
> > > > > > definitely advocate for a reduced set of 3 physical types: BIT,
> > FLBA
> > > > > > and VLBA.
> > > > > >
> > > > >
> > > > > +1 to FLBA and VLBA. What would BIT represent? Could you elaborate?
> > > > >
> > > >
> > >
> >
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-10 Thread Ryan Blue
I think it would be fine to have an int64 with a duration logical type
parameterized by unit. That fits with the timestamp types that we have
defined, which are also parameterized by unit. Iceberg is going to be more
strict about what can be produced, but this is probably a good idea for
Parquet.

On Thu, Jul 10, 2025 at 10:38 AM Micah Kornfield 
wrote:

> >
> > Quick question: is there a good reason not to just have a logical
> Duration
> > that annotates an int64 and let the unit be parameterized instead of hard
> > coding it to be nanoseconds?
>
>
> It adds additional effort/complexity for engines to consider each unit
> (perhaps minimal)? I do think it's reasonable to parameterize `TimeUnit`
> for consistency and future proofing but for now we should say it only
> supports Nanoseconds (unless someone is signing up to support the other
> units in the implementation).
>
> I think the point was raised previously that hard-coded names were
> preferred but I don't recall if that was when we were still calling this
> DayTime?
>
> Cheers,
> Micah
>
> On Thu, Jul 10, 2025 at 9:58 AM Matt Topol  wrote:
>
> > Quick question: is there a good reason not to just have a logical
> Duration
> > that annotates an int64 and let the unit be parameterized instead of hard
> > coding it to be nanoseconds?
> >
> > That would at least allow the full 10k years for other units, and allow
> > better compression if nanosecond precision isn't needed.
> >
> > Thoughts?
> >
> > On Wed, Jul 9, 2025, 11:02 AM Micah Kornfield 
> > wrote:
> >
> > > OK to summarize what I think the current proposal for interval type is
> > two
> > > new logical types:
> > >
> > > 1.  YearMonth interval annotates an int32.
> > > 2.  DurationNanos annotates an int64.
> > >
> > > There is now a separate thread, on int128 vs FLBA. Given the current
> > > proposal I don't think this blocks anything.  The main difficulty in
> > adding
> > > a newly annotated physical type would be API design allowing a
> > potentially
> > > wider type in the future.  I think this is tractable but any blockers
> > could
> > > be discovered in the implementation phase?
> > >
> > > > +1 to FLBA and VLBA. What would BIT represent? Could you elaborate
> > >
> > > I think the intent would be boolean.
> > >
> > > On Wednesday, July 9, 2025, Alkis Evlogimenos
> > >  wrote:
> > >
> > > > On Wed, Jul 9, 2025 at 11:05 AM Antoine Pitrou 
> > > wrote:
> > > >
> > > > > But if we were designing a new Parquet format from scratch, I would
> > > > > definitely advocate for a reduced set of 3 physical types: BIT,
> FLBA
> > > > > and VLBA.
> > > > >
> > > >
> > > > +1 to FLBA and VLBA. What would BIT represent? Could you elaborate?
> > > >
> > >
> >
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-10 Thread Micah Kornfield
>
> Quick question: is there a good reason not to just have a logical Duration
> that annotates an int64 and let the unit be parameterized instead of hard
> coding it to be nanoseconds?


It adds additional effort/complexity for engines to consider each unit
(perhaps minimal)? I do think it's reasonable to parameterize `TimeUnit`
for consistency and future proofing but for now we should say it only
supports Nanoseconds (unless someone is signing up to support the other
units in the implementation).

I think the point was raised previously that hard-coded names were
preferred but I don't recall if that was when we were still calling this
DayTime?

Cheers,
Micah

On Thu, Jul 10, 2025 at 9:58 AM Matt Topol  wrote:

> Quick question: is there a good reason not to just have a logical Duration
> that annotates an int64 and let the unit be parameterized instead of hard
> coding it to be nanoseconds?
>
> That would at least allow the full 10k years for other units, and allow
> better compression if nanosecond precision isn't needed.
>
> Thoughts?
>
> On Wed, Jul 9, 2025, 11:02 AM Micah Kornfield 
> wrote:
>
> > OK to summarize what I think the current proposal for interval type is
> two
> > new logical types:
> >
> > 1.  YearMonth interval annotates an int32.
> > 2.  DurationNanos annotates an int64.
> >
> > There is now a separate thread, on int128 vs FLBA. Given the current
> > proposal I don't think this blocks anything.  The main difficulty in
> adding
> > a newly annotated physical type would be API design allowing a
> potentially
> > wider type in the future.  I think this is tractable but any blockers
> could
> > be discovered in the implementation phase?
> >
> > > +1 to FLBA and VLBA. What would BIT represent? Could you elaborate
> >
> > I think the intent would be boolean.
> >
> > On Wednesday, July 9, 2025, Alkis Evlogimenos
> >  wrote:
> >
> > > On Wed, Jul 9, 2025 at 11:05 AM Antoine Pitrou 
> > wrote:
> > >
> > > > But if we were designing a new Parquet format from scratch, I would
> > > > definitely advocate for a reduced set of 3 physical types: BIT, FLBA
> > > > and VLBA.
> > > >
> > >
> > > +1 to FLBA and VLBA. What would BIT represent? Could you elaborate?
> > >
> >
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-10 Thread Matt Topol
Quick question: is there a good reason not to just have a logical Duration
that annotates an int64 and let the unit be parameterized instead of hard
coding it to be nanoseconds?

That would at least allow the full 10k years for other units, and allow
better compression if nanosecond precision isn't needed.

Thoughts?

On Wed, Jul 9, 2025, 11:02 AM Micah Kornfield  wrote:

> OK to summarize what I think the current proposal for interval type is two
> new logical types:
>
> 1.  YearMonth interval annotates an int32.
> 2.  DurationNanos annotates an int64.
>
> There is now a separate thread, on int128 vs FLBA. Given the current
> proposal I don't think this blocks anything.  The main difficulty in adding
> a newly annotated physical type would be API design allowing a potentially
> wider type in the future.  I think this is tractable but any blockers could
> be discovered in the implementation phase?
>
> > +1 to FLBA and VLBA. What would BIT represent? Could you elaborate
>
> I think the intent would be boolean.
>
> On Wednesday, July 9, 2025, Alkis Evlogimenos
>  wrote:
>
> > On Wed, Jul 9, 2025 at 11:05 AM Antoine Pitrou 
> wrote:
> >
> > > But if we were designing a new Parquet format from scratch, I would
> > > definitely advocate for a reduced set of 3 physical types: BIT, FLBA
> > > and VLBA.
> > >
> >
> > +1 to FLBA and VLBA. What would BIT represent? Could you elaborate?
> >
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-09 Thread Micah Kornfield
OK to summarize what I think the current proposal for interval type is two
new logical types:

1.  YearMonth interval annotates an int32.
2.  DurationNanos annotates an int64.

There is now a separate thread, on int128 vs FLBA. Given the current
proposal I don't think this blocks anything.  The main difficulty in adding
a newly annotated physical type would be API design allowing a potentially
wider type in the future.  I think this is tractable but any blockers could
be discovered in the implementation phase?

> +1 to FLBA and VLBA. What would BIT represent? Could you elaborate

I think the intent would be boolean.

On Wednesday, July 9, 2025, Alkis Evlogimenos
 wrote:

> On Wed, Jul 9, 2025 at 11:05 AM Antoine Pitrou  wrote:
>
> > But if we were designing a new Parquet format from scratch, I would
> > definitely advocate for a reduced set of 3 physical types: BIT, FLBA
> > and VLBA.
> >
>
> +1 to FLBA and VLBA. What would BIT represent? Could you elaborate?
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-09 Thread Alkis Evlogimenos
On Wed, Jul 9, 2025 at 11:05 AM Antoine Pitrou  wrote:

> But if we were designing a new Parquet format from scratch, I would
> definitely advocate for a reduced set of 3 physical types: BIT, FLBA
> and VLBA.
>

+1 to FLBA and VLBA. What would BIT represent? Could you elaborate?


Re: [Discussion] Follow up discussion for Interval Type

2025-07-09 Thread Antoine Pitrou
On Tue, 8 Jul 2025 10:03:35 -0700
Micah Kornfield 
wrote:
> 
> I don't have a problem with FLBA(10) but I
> > would hope
> > we could do some better encoding tricks with an Int128  
> 
> Yes, hopefully we can get some better integer encodings in place that
> would apply across the board.

Adding a new physical type just to have "better encodings" does not
make sense, IMHO.

Instead, you can define or generalize those encodings to also apply to
FLBA(N) (at least for some values of N). That would for example benefit
DECIMAL128 columns. That's what we did for BYTE_STREAM_SPLIT.

Regards

Antoine.




Re: [Discussion] Follow up discussion for Interval Type

2025-07-09 Thread Antoine Pitrou
On Mon, 7 Jul 2025 13:08:31 +0300
Alkis Evlogimenos

wrote:
> One benefit of INT128 is that it will have natural ordering for INTERVAL
> while FLBA will not.

Ordering should be defined at the logical type level, not physical type.

> If we agree that FLBA(16) is better repr for an integer of 128 bits
> (through logical type annotation) would this mean we should consider
> deprecating INT32/INT64/FLOAT/DOUBLE in favor of FBLA(4)/FBLA(8) with
> logical types?

It depends what "deprecating" entails. We do not want to disrupt the
ecosystem needlessly.

But if we were designing a new Parquet format from scratch, I would
definitely advocate for a reduced set of 3 physical types: BIT, FLBA
and VLBA.

Regards

Antoine.




Re: [Discussion] Follow up discussion for Interval Type

2025-07-08 Thread yun zou
Hi Micah,

Thanks a lot for the feedback!

> The second type, I think, can just be called Duration and be parameterized
> with a single enum that contains nanoseconds (which allows it to expand to
> support other granularities if needed)

The parameterized approach was also mentioned in the last discussion. It
seems that most people prefer a simpler type with a fixed representation
that
can cover the majority of use cases.
I recall people pointed out that Parquet has a type using a parameterized
representation, but it turned out to be overly complex and didn’t work out
well
 in practice—though I don’t have detailed insight into that myself.
Maybe @Russell Spitzer  has a better
insight about the parameterized representation story?

Best Regards,
Yun


On Tue, Jul 8, 2025 at 10:03 AM Micah Kornfield 
wrote:

> >
> > I'm in favor of the CalendarDuration and TimeDuration
>
>
> I'm bikeshedding now but:
>
> YearMonthInterval I think works for the first type, the language and type
> lines up with ANSI SQL and an Arrow type so I think there is little
> ambiguity.
>
> The second type, I think, can just be called Duration and be parameterized
> with a single enum that contains nanoseconds (which allows it to expand to
> support other granularities if needed).  Thoughts?  IIUC based on all the
> discussion Day Time Interval as proposed aligns with Arrow's definition
>  [1] of
> Duration?
>
> I don't have a problem with FLBA(10) but I
> > would hope
> > we could do some better encoding tricks with an Int128
>
>
> Yes, hopefully we can get some better integer encodings in place that
> would apply across the board.
>
> Cheers,
> Micah
>
> [1] https://github.com/apache/arrow/blob/main/format/Schema.fbs#L423
>
> On Tue, Jul 8, 2025 at 9:28 AM Russell Spitzer 
> wrote:
>
> > I'm in favor of the CalendarDuration and TimeDuration types as better
> names
> > for what we are trying to express here. I also think going forward with
> > Int64 for
> > now probably makes sense with us also doing some work to start getting an
> > official int128 in as well. I don't have a problem with FLBA(10) but I
> > would hope
> > we could do some better encoding tricks with an Int128. I'm relatively a
> > novice
> > in this area so take that with a grain of salt.
> >
> > On Mon, Jul 7, 2025 at 10:39 PM Micah Kornfield 
> > wrote:
> >
> > > >
> > > > However, the reverse is not guaranteed: a MonthDayNano value cannot
> > > > reliably be converted back
> > > > into a DayTimeInterval. This is because there's no way to determine
> > > whether
> > > > the calendar component
> > > > is used without looking into the data, which introduces ambiguity.
> This
> > > > ambiguity can negatively impact
> > > > interoperability across different engines and systems.
> > >
> > >
> > > Ultimately, this is something that systems will need to deal with at
> some
> > > point but this can delayed until someone has the bandwidth to have a
> > formal
> > > proposal for persisting MonthDayNano in parquet (and it would still be
> up
> > > to the consuming system on how to do the translation so I'm not clear
> > that
> > > defining the translation is strictly necessary).
> > >
> > >
> > > > Regarding whether we should use FLBA(16) or INT128, while INT128 does
> > > have
> > > > a natural
> > > > fitting for ordering, I think one concern I had is if that type will
> > only
> > > > be used by the Day Time Interval.
> > >
> > >
> > > I think there are a few use-cases that have at least been mentioned
> where
> > > it would be useful to have int128:
> > >
> > > 1.  A replacement for int96 timestamp that can handle the full range of
> > > ANSI SQL Nanoseconds.
> > > 2.  Picoseconds has at least been mentioned in passing and that would
> > > require int128.
> > >
> > > If we don't model it as a 128 we should minimize the range to reflect
> > what
> > > ANSI SQL requires (i.e. FLBA(10) I believe). We should probably allow
> the
> > > logical type to annotate both int64 and FLBA(10), since int64 is a
> common
> > > representation for nanoseconds (this is similar to what we already do
> for
> > > Decimal values).
> > >
> > > Regarding the name for DayTimeInterval, if we all agree that "Duration"
> > > > provides better clarity,
> > > > I'm fully on board with using that instead.
> > >
> > >
> > > +1, IIUC I think this addresses the majority of concerns.  If others in
> > the
> > > community want to define a parquet representation for MonthDayNanos
> arrow
> > > interval that would be welcome as well. I think the main question then
> > > becomes on Arrow side if we want to define the new type or deal with
> the
> > > unlikely case of overflow for the duration type.
> > >
> > >
> > >
> > > On Mon, Jul 7, 2025 at 4:38 PM yun zou 
> > wrote:
> > >
> > > > Hi,
> > > >
> > > > Thanks all for the valuable feedback!
> > > >
> > > > Regarding the MonthDayNano type, one important point that may not be
> > > > explicitly 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-08 Thread Micah Kornfield
>
> I'm in favor of the CalendarDuration and TimeDuration


I'm bikeshedding now but:

YearMonthInterval I think works for the first type, the language and type
lines up with ANSI SQL and an Arrow type so I think there is little
ambiguity.

The second type, I think, can just be called Duration and be parameterized
with a single enum that contains nanoseconds (which allows it to expand to
support other granularities if needed).  Thoughts?  IIUC based on all the
discussion Day Time Interval as proposed aligns with Arrow's definition
 [1] of
Duration?

I don't have a problem with FLBA(10) but I
> would hope
> we could do some better encoding tricks with an Int128


Yes, hopefully we can get some better integer encodings in place that
would apply across the board.

Cheers,
Micah

[1] https://github.com/apache/arrow/blob/main/format/Schema.fbs#L423

On Tue, Jul 8, 2025 at 9:28 AM Russell Spitzer 
wrote:

> I'm in favor of the CalendarDuration and TimeDuration types as better names
> for what we are trying to express here. I also think going forward with
> Int64 for
> now probably makes sense with us also doing some work to start getting an
> official int128 in as well. I don't have a problem with FLBA(10) but I
> would hope
> we could do some better encoding tricks with an Int128. I'm relatively a
> novice
> in this area so take that with a grain of salt.
>
> On Mon, Jul 7, 2025 at 10:39 PM Micah Kornfield 
> wrote:
>
> > >
> > > However, the reverse is not guaranteed: a MonthDayNano value cannot
> > > reliably be converted back
> > > into a DayTimeInterval. This is because there's no way to determine
> > whether
> > > the calendar component
> > > is used without looking into the data, which introduces ambiguity. This
> > > ambiguity can negatively impact
> > > interoperability across different engines and systems.
> >
> >
> > Ultimately, this is something that systems will need to deal with at some
> > point but this can delayed until someone has the bandwidth to have a
> formal
> > proposal for persisting MonthDayNano in parquet (and it would still be up
> > to the consuming system on how to do the translation so I'm not clear
> that
> > defining the translation is strictly necessary).
> >
> >
> > > Regarding whether we should use FLBA(16) or INT128, while INT128 does
> > have
> > > a natural
> > > fitting for ordering, I think one concern I had is if that type will
> only
> > > be used by the Day Time Interval.
> >
> >
> > I think there are a few use-cases that have at least been mentioned where
> > it would be useful to have int128:
> >
> > 1.  A replacement for int96 timestamp that can handle the full range of
> > ANSI SQL Nanoseconds.
> > 2.  Picoseconds has at least been mentioned in passing and that would
> > require int128.
> >
> > If we don't model it as a 128 we should minimize the range to reflect
> what
> > ANSI SQL requires (i.e. FLBA(10) I believe). We should probably allow the
> > logical type to annotate both int64 and FLBA(10), since int64 is a common
> > representation for nanoseconds (this is similar to what we already do for
> > Decimal values).
> >
> > Regarding the name for DayTimeInterval, if we all agree that "Duration"
> > > provides better clarity,
> > > I'm fully on board with using that instead.
> >
> >
> > +1, IIUC I think this addresses the majority of concerns.  If others in
> the
> > community want to define a parquet representation for MonthDayNanos arrow
> > interval that would be welcome as well. I think the main question then
> > becomes on Arrow side if we want to define the new type or deal with the
> > unlikely case of overflow for the duration type.
> >
> >
> >
> > On Mon, Jul 7, 2025 at 4:38 PM yun zou 
> wrote:
> >
> > > Hi,
> > >
> > > Thanks all for the valuable feedback!
> > >
> > > Regarding the MonthDayNano type, one important point that may not be
> > > explicitly stated
> > > is the lack of true interoperability between YearMonthInterval,
> > > DayTimeInterval, and MonthDayNano.
> > >
> > > While YearMonthInterval and DayTimeInterval are not directly
> > interoperable
> > > with each other,
> > > they can both be converted into MonthDayNano by setting certain
> > components
> > > to zero.
> > > However, the reverse is not guaranteed: a MonthDayNano value cannot
> > > reliably be converted back
> > > into a DayTimeInterval. This is because there's no way to determine
> > whether
> > > the calendar component
> > > is used without looking into the data, which introduces ambiguity. This
> > > ambiguity can negatively impact
> > > interoperability across different engines and systems.
> > >
> > > > Doesn't capture semantics for engines that treat day as a calendar
> > type.
> > > I don't actually see the above as a drawback of introducing two
> separate
> > > interval types,
> > > since when the day is used as a calendar type, it can be mapped to the
> > > MonthDayNano type.
> > > In fact, I believe 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-08 Thread Russell Spitzer
I'm in favor of the CalendarDuration and TimeDuration types as better names
for what we are trying to express here. I also think going forward with
Int64 for
now probably makes sense with us also doing some work to start getting an
official int128 in as well. I don't have a problem with FLBA(10) but I
would hope
we could do some better encoding tricks with an Int128. I'm relatively a
novice
in this area so take that with a grain of salt.

On Mon, Jul 7, 2025 at 10:39 PM Micah Kornfield 
wrote:

> >
> > However, the reverse is not guaranteed: a MonthDayNano value cannot
> > reliably be converted back
> > into a DayTimeInterval. This is because there's no way to determine
> whether
> > the calendar component
> > is used without looking into the data, which introduces ambiguity. This
> > ambiguity can negatively impact
> > interoperability across different engines and systems.
>
>
> Ultimately, this is something that systems will need to deal with at some
> point but this can delayed until someone has the bandwidth to have a formal
> proposal for persisting MonthDayNano in parquet (and it would still be up
> to the consuming system on how to do the translation so I'm not clear that
> defining the translation is strictly necessary).
>
>
> > Regarding whether we should use FLBA(16) or INT128, while INT128 does
> have
> > a natural
> > fitting for ordering, I think one concern I had is if that type will only
> > be used by the Day Time Interval.
>
>
> I think there are a few use-cases that have at least been mentioned where
> it would be useful to have int128:
>
> 1.  A replacement for int96 timestamp that can handle the full range of
> ANSI SQL Nanoseconds.
> 2.  Picoseconds has at least been mentioned in passing and that would
> require int128.
>
> If we don't model it as a 128 we should minimize the range to reflect what
> ANSI SQL requires (i.e. FLBA(10) I believe). We should probably allow the
> logical type to annotate both int64 and FLBA(10), since int64 is a common
> representation for nanoseconds (this is similar to what we already do for
> Decimal values).
>
> Regarding the name for DayTimeInterval, if we all agree that "Duration"
> > provides better clarity,
> > I'm fully on board with using that instead.
>
>
> +1, IIUC I think this addresses the majority of concerns.  If others in the
> community want to define a parquet representation for MonthDayNanos arrow
> interval that would be welcome as well. I think the main question then
> becomes on Arrow side if we want to define the new type or deal with the
> unlikely case of overflow for the duration type.
>
>
>
> On Mon, Jul 7, 2025 at 4:38 PM yun zou  wrote:
>
> > Hi,
> >
> > Thanks all for the valuable feedback!
> >
> > Regarding the MonthDayNano type, one important point that may not be
> > explicitly stated
> > is the lack of true interoperability between YearMonthInterval,
> > DayTimeInterval, and MonthDayNano.
> >
> > While YearMonthInterval and DayTimeInterval are not directly
> interoperable
> > with each other,
> > they can both be converted into MonthDayNano by setting certain
> components
> > to zero.
> > However, the reverse is not guaranteed: a MonthDayNano value cannot
> > reliably be converted back
> > into a DayTimeInterval. This is because there's no way to determine
> whether
> > the calendar component
> > is used without looking into the data, which introduces ambiguity. This
> > ambiguity can negatively impact
> > interoperability across different engines and systems.
> >
> > > Doesn't capture semantics for engines that treat day as a calendar
> type.
> > I don't actually see the above as a drawback of introducing two separate
> > interval types,
> > since when the day is used as a calendar type, it can be mapped to the
> > MonthDayNano type.
> > In fact, I believe all three types are necessary to fully support the
> range
> > of use cases.
> > What’s important is that we clearly define the interoperability rules
> > between them to ensure
> > consistent behavior across systems.
> >
> > > While I understand the desire to be able to represent all values
> > > allowable in ANSI SQL, I really don't understand why our types should
> > > not be allowed to represent any values *outside* of the range allowed
> > > in ANSI SQL.
> > I completely agree—if there are valid use cases beyond ANSI SQL, we
> should
> > absolutely support them. It makes sense to leave range validation to the
> > engine or
> > client implementation, as they are best suited to handle their own
> specific
> > requirements..
> >
> > Regarding whether we should use FLBA(16) or INT128, while INT128 does
> have
> > a natural
> > fitting for ordering, I think one concern I had is if that type will only
> > be used by the Day Time Interval.
> >
> > Regarding the name for DayTimeInterval, if we all agree that "Duration"
> > provides better clarity,
> > I'm fully on board with using that instead.
> >
> > Best Regards,
> > Yun
> >
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-07 Thread Raphael Taylor-Davies

Thank you, that looks like a good summary to me.

I guess a third option would be for the new INTERVAL_DAY_TIME to 
annotate a composite type of days and milliseconds, as originally 
proposed back in 2016 [1]. This would have the benefit of preserving the 
information necessary for engines to treat days as calendar days if they 
choose to do so, whilst also mapping to an existing arrow data type. For 
the purposes of a sort order days could be defined as 24 hours, with 
engines free to ignore this if they wish to treat intervals differently. 
The major downside is no nanosecond precision.


A fourth possibility I can see, that could also be done in parallel, 
would be to define varying precision duration types similar to 
timestamps. This would be functionally identical to the proposed 
DAY-TIME integer, but without the rather confusing characteristic of not 
actually storing a number of days or really being an interval in the 
universally understood sense. This would also provide a standardized way 
to map the arrow duration types, which currently rely on arrow-specific 
metadata to be encoded.


I'm sure people smarter than I can devise further alternative proposals, 
however, I think that any proposal must preserve existing functionality 
for it to be well adopted. In particular any proposal without a good 
story for encoding calendar days and mapping to arrow is likely to fail 
to replace the existing INTERVAL type for which these are well defined.


Kind Regards,

Raphael

[1]: https://github.com/apache/parquet-format/pull/43

On 07/07/2025 07:37, Micah Kornfield wrote:

I think I've lost the thread a little bit on this discussion.  I'd like to
try to summarize my understanding of the issues at hand and current
proposals.

As a short summary, my understanding of the requirements we want for a new
parquet day-time interval type are:

1.  Represent +/- 10K years for at least nano-second granularity (IIUC the
range is specified by ANSI SQL.  The granularity is picked for convenience
that covers most use cases).
2.  Allow pruning via min-max statistics

Shortcomings of the existing interval type:
1.  Millisecond granularity.
2.  Only supports positive values (all integer in FLBA of 12 bytes are
unsigned).
3.  No sort order

Proposals:
1.  Fixed width integer duration type (assumes days are always exactly
86400 seconds)
 Pros:
- Easy to model.
- Maps easily to ANSI SQL Day Time Interval representations that
several engines use.
 Cons:
- Doesn't match well with any Arrow type.
- Doesn't capture semantics for engines that treat day as a calendar
type.

2.  IIUC, Something based off of Arrow's MonthDayNanos type.  I apologize,
I'm not sure if this is what is being proposed but here are the approaches
i see with this:
- FLBA 16 byte type exactly like arrow
- Shredded (month, day and nanos each have a separate field under a
struct).  The main complication with this would be statistics since it is
all on the leaf fields, so there is either some information loss OR a
convention for recording statistics on one of the leafs need to followed).

- Pros:
   - Potentially more efficient storage
   - Maps directly to one of Arrow's Interval types.
- Cons:
   - Comparison in general is challenging. Perhaps this can be solved by
new sort order that clarify relationships between fields or additional
metadata on the logic type. e.g. UNORDERED (Arrow semantics) or YEAR-MONTH
(only month field is expected to be populated and values are ordered on it)
or  DAY-TIME ordered (A day means 86400 seconds and nanoseconds normalized
to be less then 24 hours).
   - Doesn't conform to the notion of ANSI SQL interval types (which
have two separate representations for Year/Month and Day Time).  So some
parquet files might not be readable by ANSI SQL.
   - For the likely uncommon case (intervals ~+/- 200 years) might
require more transformation to an engine's internal representation.
   - Only works for the SQL standard if days are assumed to be 86400
seconds (right now fields are specified as independent of each other).


Did I get the requirements right?  Are there some other options people were
thinking about?

Thanks,
Micah



On Fri, Jul 4, 2025 at 6:49 AM Antoine Pitrou  wrote:


On Thu, 3 Jul 2025 17:22:27 +0100
Raphael Taylor-Davies

wrote:

Hi,

I may be misunderstanding something, but it appears that the motivation
for this effort is that the current interval type represents a superset
of the functionality required by ANSI SQL, and therefore can cause
compatibility problems for some databases that only support the minimum
required by ANSI SQL?

While I understand the desire to be able to represent all values
allowable in ANSI SQL, I really don't understand why our types should
not be allowed to represent any values *outside* of the range allowed
in ANSI SQL.

Please let's be mindful that Parquet is not useful only for SQL-type
workloads. Besides, 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-07 Thread Alkis Evlogimenos
One benefit of INT128 is that it will have natural ordering for INTERVAL
while FLBA will not.

If we agree that FLBA(16) is better repr for an integer of 128 bits
(through logical type annotation) would this mean we should consider
deprecating INT32/INT64/FLOAT/DOUBLE in favor of FBLA(4)/FBLA(8) with
logical types?

On Mon, Jul 7, 2025 at 12:52 PM Antoine Pitrou  wrote:

>
> I don't think it makes a lot of sense to add a INT128 physical type
> while it could be FLBA(16) instead. New physical types are
> larger implementation burden than new logical types.
>
> Regards
>
> Antoine.
>
>
>
> On Mon, 7 Jul 2025 10:24:50 +0300
> Alkis Evlogimenos
> 
> wrote:
> > In the 25th June meeting the predominant suggestion was to make INTERVAL
> a
> > logical type with physical type being INT64 nanos. This does not cover
> the
> > full 10k year ANSI SQL range and the rebuttal for that is that we could
> add
> > INT128 physical type that could also be used for that and other things.
> >
> > Why wouldn't the above work?
> >
> > On Mon, Jul 7, 2025 at 9:37 AM Micah Kornfield 
> > wrote:
> >
> > > I think I've lost the thread a little bit on this discussion.  I'd
> like to
> > > try to summarize my understanding of the issues at hand and current
> > > proposals.
> > >
> > > As a short summary, my understanding of the requirements we want for a
> new
> > > parquet day-time interval type are:
> > >
> > > 1.  Represent +/- 10K years for at least nano-second granularity (IIUC
> the
> > > range is specified by ANSI SQL.  The granularity is picked for
> convenience
> > > that covers most use cases).
> > > 2.  Allow pruning via min-max statistics
> > >
> > > Shortcomings of the existing interval type:
> > > 1.  Millisecond granularity.
> > > 2.  Only supports positive values (all integer in FLBA of 12 bytes are
> > > unsigned).
> > > 3.  No sort order
> > >
> > > Proposals:
> > > 1.  Fixed width integer duration type (assumes days are always exactly
> > > 86400 seconds)
> > > Pros:
> > >- Easy to model.
> > >- Maps easily to ANSI SQL Day Time Interval representations that
> > > several engines use.
> > > Cons:
> > >- Doesn't match well with any Arrow type.
> > >- Doesn't capture semantics for engines that treat day as a
> calendar
> > > type.
> > >
> > > 2.  IIUC, Something based off of Arrow's MonthDayNanos type.  I
> apologize,
> > > I'm not sure if this is what is being proposed but here are the
> approaches
> > > i see with this:
> > >- FLBA 16 byte type exactly like arrow
> > >- Shredded (month, day and nanos each have a separate field under a
> > > struct).  The main complication with this would be statistics since it
> is
> > > all on the leaf fields, so there is either some information loss OR a
> > > convention for recording statistics on one of the leafs need to
> followed).
> > >
> > >- Pros:
> > >   - Potentially more efficient storage
> > >   - Maps directly to one of Arrow's Interval types.
> > >- Cons:
> > >   - Comparison in general is challenging. Perhaps this can be
> solved by
> > > new sort order that clarify relationships between fields or additional
> > > metadata on the logic type. e.g. UNORDERED (Arrow semantics) or
> YEAR-MONTH
> > > (only month field is expected to be populated and values are ordered
> on it)
> > > or  DAY-TIME ordered (A day means 86400 seconds and nanoseconds
> normalized
> > > to be less then 24 hours).
> > >   - Doesn't conform to the notion of ANSI SQL interval types (which
> > > have two separate representations for Year/Month and Day Time).  So
> some
> > > parquet files might not be readable by ANSI SQL.
> > >   - For the likely uncommon case (intervals ~+/- 200 years) might
> > > require more transformation to an engine's internal representation.
> > >   - Only works for the SQL standard if days are assumed to be 86400
> > > seconds (right now fields are specified as independent of each other).
> > >
> > >
> > > Did I get the requirements right?  Are there some other options people
> were
> > > thinking about?
> > >
> > > Thanks,
> > > Micah
> > >
> > >
> > >
> > > On Fri, Jul 4, 2025 at 6:49 AM Antoine Pitrou <
> [email protected]> wrote:
> > >
> > > > On Thu, 3 Jul 2025 17:22:27 +0100
> > > > Raphael Taylor-Davies
> > > > 
> > > > wrote:
> > > > > Hi,
> > > > >
> > > > > I may be misunderstanding something, but it appears that the
> motivation
> > > > > for this effort is that the current interval type represents a
> superset
> > > > > of the functionality required by ANSI SQL, and therefore can cause
> > > > > compatibility problems for some databases that only support the
> minimum
> > > > > required by ANSI SQL?
> > > >
> > > > While I understand the desire to be able to represent all values
> > > > allowable in ANSI SQL, I really don't understand why our types should
> > > > not be allowed to represent any values *outside* of the range allowed
> > > > in ANSI SQL.
> 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-07 Thread Antoine Pitrou


I don't think it makes a lot of sense to add a INT128 physical type
while it could be FLBA(16) instead. New physical types are
larger implementation burden than new logical types.

Regards

Antoine.



On Mon, 7 Jul 2025 10:24:50 +0300
Alkis Evlogimenos

wrote:
> In the 25th June meeting the predominant suggestion was to make INTERVAL a
> logical type with physical type being INT64 nanos. This does not cover the
> full 10k year ANSI SQL range and the rebuttal for that is that we could add
> INT128 physical type that could also be used for that and other things.
> 
> Why wouldn't the above work?
> 
> On Mon, Jul 7, 2025 at 9:37 AM Micah Kornfield 
> wrote:
> 
> > I think I've lost the thread a little bit on this discussion.  I'd like to
> > try to summarize my understanding of the issues at hand and current
> > proposals.
> >
> > As a short summary, my understanding of the requirements we want for a new
> > parquet day-time interval type are:
> >
> > 1.  Represent +/- 10K years for at least nano-second granularity (IIUC the
> > range is specified by ANSI SQL.  The granularity is picked for convenience
> > that covers most use cases).
> > 2.  Allow pruning via min-max statistics
> >
> > Shortcomings of the existing interval type:
> > 1.  Millisecond granularity.
> > 2.  Only supports positive values (all integer in FLBA of 12 bytes are
> > unsigned).
> > 3.  No sort order
> >
> > Proposals:
> > 1.  Fixed width integer duration type (assumes days are always exactly
> > 86400 seconds)
> > Pros:
> >- Easy to model.
> >- Maps easily to ANSI SQL Day Time Interval representations that
> > several engines use.
> > Cons:
> >- Doesn't match well with any Arrow type.
> >- Doesn't capture semantics for engines that treat day as a calendar
> > type.
> >
> > 2.  IIUC, Something based off of Arrow's MonthDayNanos type.  I apologize,
> > I'm not sure if this is what is being proposed but here are the approaches
> > i see with this:
> >- FLBA 16 byte type exactly like arrow
> >- Shredded (month, day and nanos each have a separate field under a
> > struct).  The main complication with this would be statistics since it is
> > all on the leaf fields, so there is either some information loss OR a
> > convention for recording statistics on one of the leafs need to followed).
> >
> >- Pros:
> >   - Potentially more efficient storage
> >   - Maps directly to one of Arrow's Interval types.
> >- Cons:
> >   - Comparison in general is challenging. Perhaps this can be solved by
> > new sort order that clarify relationships between fields or additional
> > metadata on the logic type. e.g. UNORDERED (Arrow semantics) or YEAR-MONTH
> > (only month field is expected to be populated and values are ordered on it)
> > or  DAY-TIME ordered (A day means 86400 seconds and nanoseconds normalized
> > to be less then 24 hours).
> >   - Doesn't conform to the notion of ANSI SQL interval types (which
> > have two separate representations for Year/Month and Day Time).  So some
> > parquet files might not be readable by ANSI SQL.
> >   - For the likely uncommon case (intervals ~+/- 200 years) might
> > require more transformation to an engine's internal representation.
> >   - Only works for the SQL standard if days are assumed to be 86400
> > seconds (right now fields are specified as independent of each other).
> >
> >
> > Did I get the requirements right?  Are there some other options people were
> > thinking about?
> >
> > Thanks,
> > Micah
> >
> >
> >
> > On Fri, Jul 4, 2025 at 6:49 AM Antoine Pitrou 
> >  wrote:
> >  
> > > On Thu, 3 Jul 2025 17:22:27 +0100
> > > Raphael Taylor-Davies
> > > 
> > > wrote:  
> > > > Hi,
> > > >
> > > > I may be misunderstanding something, but it appears that the motivation
> > > > for this effort is that the current interval type represents a superset
> > > > of the functionality required by ANSI SQL, and therefore can cause
> > > > compatibility problems for some databases that only support the minimum
> > > > required by ANSI SQL?  
> > >
> > > While I understand the desire to be able to represent all values
> > > allowable in ANSI SQL, I really don't understand why our types should
> > > not be allowed to represent any values *outside* of the range allowed
> > > in ANSI SQL.
> > >
> > > Please let's be mindful that Parquet is not useful only for SQL-type
> > > workloads. Besides, ANSI SQL itself might evolve and we don't want to
> > > add another Interval type in a few years because the one we're
> > > current specifying ends up too tight.
> > >
> > > (if some people want to make sure that values don't fall outside the
> > > ANSI SQL range, they can write a validation pass for it; no need to
> > > burden the Parquet *format* with such contraints)
> > >
> > > Regards
> > >
> > > Antoine.
> > >
> > >
> > >  
> >  
> 





Re: [Discussion] Follow up discussion for Interval Type

2025-07-07 Thread Alkis Evlogimenos
In the 25th June meeting the predominant suggestion was to make INTERVAL a
logical type with physical type being INT64 nanos. This does not cover the
full 10k year ANSI SQL range and the rebuttal for that is that we could add
INT128 physical type that could also be used for that and other things.

Why wouldn't the above work?

On Mon, Jul 7, 2025 at 9:37 AM Micah Kornfield 
wrote:

> I think I've lost the thread a little bit on this discussion.  I'd like to
> try to summarize my understanding of the issues at hand and current
> proposals.
>
> As a short summary, my understanding of the requirements we want for a new
> parquet day-time interval type are:
>
> 1.  Represent +/- 10K years for at least nano-second granularity (IIUC the
> range is specified by ANSI SQL.  The granularity is picked for convenience
> that covers most use cases).
> 2.  Allow pruning via min-max statistics
>
> Shortcomings of the existing interval type:
> 1.  Millisecond granularity.
> 2.  Only supports positive values (all integer in FLBA of 12 bytes are
> unsigned).
> 3.  No sort order
>
> Proposals:
> 1.  Fixed width integer duration type (assumes days are always exactly
> 86400 seconds)
> Pros:
>- Easy to model.
>- Maps easily to ANSI SQL Day Time Interval representations that
> several engines use.
> Cons:
>- Doesn't match well with any Arrow type.
>- Doesn't capture semantics for engines that treat day as a calendar
> type.
>
> 2.  IIUC, Something based off of Arrow's MonthDayNanos type.  I apologize,
> I'm not sure if this is what is being proposed but here are the approaches
> i see with this:
>- FLBA 16 byte type exactly like arrow
>- Shredded (month, day and nanos each have a separate field under a
> struct).  The main complication with this would be statistics since it is
> all on the leaf fields, so there is either some information loss OR a
> convention for recording statistics on one of the leafs need to followed).
>
>- Pros:
>   - Potentially more efficient storage
>   - Maps directly to one of Arrow's Interval types.
>- Cons:
>   - Comparison in general is challenging. Perhaps this can be solved by
> new sort order that clarify relationships between fields or additional
> metadata on the logic type. e.g. UNORDERED (Arrow semantics) or YEAR-MONTH
> (only month field is expected to be populated and values are ordered on it)
> or  DAY-TIME ordered (A day means 86400 seconds and nanoseconds normalized
> to be less then 24 hours).
>   - Doesn't conform to the notion of ANSI SQL interval types (which
> have two separate representations for Year/Month and Day Time).  So some
> parquet files might not be readable by ANSI SQL.
>   - For the likely uncommon case (intervals ~+/- 200 years) might
> require more transformation to an engine's internal representation.
>   - Only works for the SQL standard if days are assumed to be 86400
> seconds (right now fields are specified as independent of each other).
>
>
> Did I get the requirements right?  Are there some other options people were
> thinking about?
>
> Thanks,
> Micah
>
>
>
> On Fri, Jul 4, 2025 at 6:49 AM Antoine Pitrou  wrote:
>
> > On Thu, 3 Jul 2025 17:22:27 +0100
> > Raphael Taylor-Davies
> > 
> > wrote:
> > > Hi,
> > >
> > > I may be misunderstanding something, but it appears that the motivation
> > > for this effort is that the current interval type represents a superset
> > > of the functionality required by ANSI SQL, and therefore can cause
> > > compatibility problems for some databases that only support the minimum
> > > required by ANSI SQL?
> >
> > While I understand the desire to be able to represent all values
> > allowable in ANSI SQL, I really don't understand why our types should
> > not be allowed to represent any values *outside* of the range allowed
> > in ANSI SQL.
> >
> > Please let's be mindful that Parquet is not useful only for SQL-type
> > workloads. Besides, ANSI SQL itself might evolve and we don't want to
> > add another Interval type in a few years because the one we're
> > current specifying ends up too tight.
> >
> > (if some people want to make sure that values don't fall outside the
> > ANSI SQL range, they can write a validation pass for it; no need to
> > burden the Parquet *format* with such contraints)
> >
> > Regards
> >
> > Antoine.
> >
> >
> >
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-06 Thread Micah Kornfield
I think I've lost the thread a little bit on this discussion.  I'd like to
try to summarize my understanding of the issues at hand and current
proposals.

As a short summary, my understanding of the requirements we want for a new
parquet day-time interval type are:

1.  Represent +/- 10K years for at least nano-second granularity (IIUC the
range is specified by ANSI SQL.  The granularity is picked for convenience
that covers most use cases).
2.  Allow pruning via min-max statistics

Shortcomings of the existing interval type:
1.  Millisecond granularity.
2.  Only supports positive values (all integer in FLBA of 12 bytes are
unsigned).
3.  No sort order

Proposals:
1.  Fixed width integer duration type (assumes days are always exactly
86400 seconds)
Pros:
   - Easy to model.
   - Maps easily to ANSI SQL Day Time Interval representations that
several engines use.
Cons:
   - Doesn't match well with any Arrow type.
   - Doesn't capture semantics for engines that treat day as a calendar
type.

2.  IIUC, Something based off of Arrow's MonthDayNanos type.  I apologize,
I'm not sure if this is what is being proposed but here are the approaches
i see with this:
   - FLBA 16 byte type exactly like arrow
   - Shredded (month, day and nanos each have a separate field under a
struct).  The main complication with this would be statistics since it is
all on the leaf fields, so there is either some information loss OR a
convention for recording statistics on one of the leafs need to followed).

   - Pros:
  - Potentially more efficient storage
  - Maps directly to one of Arrow's Interval types.
   - Cons:
  - Comparison in general is challenging. Perhaps this can be solved by
new sort order that clarify relationships between fields or additional
metadata on the logic type. e.g. UNORDERED (Arrow semantics) or YEAR-MONTH
(only month field is expected to be populated and values are ordered on it)
or  DAY-TIME ordered (A day means 86400 seconds and nanoseconds normalized
to be less then 24 hours).
  - Doesn't conform to the notion of ANSI SQL interval types (which
have two separate representations for Year/Month and Day Time).  So some
parquet files might not be readable by ANSI SQL.
  - For the likely uncommon case (intervals ~+/- 200 years) might
require more transformation to an engine's internal representation.
  - Only works for the SQL standard if days are assumed to be 86400
seconds (right now fields are specified as independent of each other).


Did I get the requirements right?  Are there some other options people were
thinking about?

Thanks,
Micah



On Fri, Jul 4, 2025 at 6:49 AM Antoine Pitrou  wrote:

> On Thu, 3 Jul 2025 17:22:27 +0100
> Raphael Taylor-Davies
> 
> wrote:
> > Hi,
> >
> > I may be misunderstanding something, but it appears that the motivation
> > for this effort is that the current interval type represents a superset
> > of the functionality required by ANSI SQL, and therefore can cause
> > compatibility problems for some databases that only support the minimum
> > required by ANSI SQL?
>
> While I understand the desire to be able to represent all values
> allowable in ANSI SQL, I really don't understand why our types should
> not be allowed to represent any values *outside* of the range allowed
> in ANSI SQL.
>
> Please let's be mindful that Parquet is not useful only for SQL-type
> workloads. Besides, ANSI SQL itself might evolve and we don't want to
> add another Interval type in a few years because the one we're
> current specifying ends up too tight.
>
> (if some people want to make sure that values don't fall outside the
> ANSI SQL range, they can write a validation pass for it; no need to
> burden the Parquet *format* with such contraints)
>
> Regards
>
> Antoine.
>
>
>


Re: [Discussion] Follow up discussion for Interval Type

2025-07-04 Thread Antoine Pitrou
On Thu, 3 Jul 2025 17:22:27 +0100
Raphael Taylor-Davies

wrote:
> Hi,
> 
> I may be misunderstanding something, but it appears that the motivation 
> for this effort is that the current interval type represents a superset 
> of the functionality required by ANSI SQL, and therefore can cause 
> compatibility problems for some databases that only support the minimum 
> required by ANSI SQL?

While I understand the desire to be able to represent all values
allowable in ANSI SQL, I really don't understand why our types should
not be allowed to represent any values *outside* of the range allowed
in ANSI SQL.

Please let's be mindful that Parquet is not useful only for SQL-type
workloads. Besides, ANSI SQL itself might evolve and we don't want to
add another Interval type in a few years because the one we're
current specifying ends up too tight.

(if some people want to make sure that values don't fall outside the
ANSI SQL range, they can write a validation pass for it; no need to
burden the Parquet *format* with such contraints)

Regards

Antoine.




Re: [Discussion] Follow up discussion for Interval Type

2025-07-03 Thread Raphael Taylor-Davies
Right so of the two databases listed that support DST timezones, oracle
treats them as 24 hours and postgres as a calendar day. Would it be fair
therefore to conclude the SQL standard simply doesn't specify this
behaviour? As such should data formats be designed in such a way to allow
query engines to implement the semantic of their or their users choosing?

On Thu, 3 Jul 2025, 18:48 Micah Kornfield,  wrote:

>
> https://stackoverflow.com/questions/61505068/is-interval-1-day-always-equal-to-interval-24-hours
> comes up when doing a web search for this.
>
> On Thu, Jul 3, 2025 at 10:39 AM Raphael Taylor-Davies
>  wrote:
>
> > I could be mistaken, but I seem to remember ANSI SQL doesn't have
> > timezones, and therefore as far as it is concerned days can only have 24
> > hours. Whether this assumption should be preserved in databases that
> > support timezones though...
> >
> > On Thu, 3 Jul 2025, 18:32 Micah Kornfield, 
> wrote:
> >
> > > >
> > > > Putting this to one side, I think the proposed DayTimeInterval still
> > > > needs a separate day component in order to be SQL compliant, as days
> > may
> > > > not have 24 hours due to daylight savings time. I think what is being
> > > > suggested might be better described as a duration type.
> > >
> > >
> > > This has come up a few times.  It seems the SQL spec defines 1 day as
> > > exactly 24 hours (86400) seconds for the purpose of intervals.  So yes
> it
> > > is in fact a duration.  Postgres and BigQuery seem to be the two SQL
> > > systems I'm aware of that treat day components in the "calendar" sense
> > > instead of the duration sense.
> > >
> > > I wonder if people would be more comfortable not calling it DayTime
> > > Interval and instead calling it a duration.  From the perspective of
> > > arrow<->parquet interop since there is already a Nanosecond duration,
> > > perhaps we should jump to Picoseconds and use int128 which I think
> would
> > > satisfy the SQL requirements as well or allow for the fact that
> > > Parquet's duration nanoseconds could potentially overflow Arrow's
> > duration
> > > seconds?
> > >
> > > Thanks,
> > > Micah
> > >
> > > On Thu, Jul 3, 2025 at 9:22 AM Raphael Taylor-Davies
> > >  wrote:
> > >
> > > > Hi,
> > > >
> > > > I may be misunderstanding something, but it appears that the
> motivation
> > > > for this effort is that the current interval type represents a
> superset
> > > > of the functionality required by ANSI SQL, and therefore can cause
> > > > compatibility problems for some databases that only support the
> minimum
> > > > required by ANSI SQL?
> > > >
> > > > In particular the parquet Interval (along with Arrow's MonthDayNano
> and
> > > > postgres' interval) encode a number of months, days and some seconds
> in
> > > > a single unified interval type, whereas the SQL standard instead
> > defines
> > > > two interval types - one consisting of a combination of years and
> > > > months, and another days and some seconds quantity.
> > > >
> > > > Whilst I can see that bifurcating the parquet interval types to match
> > > > the minimum required by the SQL standard might help those systems
> with
> > > > such bifurcated interval types, it will be a net negative for those
> > > > systems that instead have a unified interval type. I therefore
> suspect
> > > > this will end up being a repeat of the ongoing Int96 saga, especially
> > as
> > > > IMO having a unified interval representation is a significant UX
> > > > improvement whilst also providing strictly more functionality. I
> wonder
> > > > if instead it might be better to define some mapping that can be used
> > by
> > > > systems with bifurcated interval types - perhaps as a struct column
> > > > consisting of the two components? This would avoid an interminable
> > > > migration period, whilst also not representing a loss of
> functionality
> > > > or ergonomics for existing workloads.
> > > >
> > > > Putting this to one side, I think the proposed DayTimeInterval still
> > > > needs a separate day component in order to be SQL compliant, as days
> > may
> > > > not have 24 hours due to daylight savings time. I think what is being
> > > > suggested might be better described as a duration type.
> > > >
> > > > Kind Regards,
> > > >
> > > > Raphael
> > > >
> > > > On 03/07/2025 16:01, Felipe Oliveira Carvalho wrote:
> > > > > Hi,
> > > > >
> > > > > I recently took the time to understand MonthDayNano better and it's
> > not
> > > > as
> > > > > crazy as my first impression of it.
> > > > >
> > > > > I think we could solve many of the problems you're trying to solve
> by
> > > > > embracing it. Replies inline:
> > > > >
> > > > > On Tue, Jul 1, 2025 at 2:56 AM yun zou  >
> > > > wrote:
> > > > >
> > > > >> Hi Team,
> > > > >>
> > > > >> Resending the previous email about the Interval Type discussion
> from
> > > the
> > > > >> last Parquet community sync, with some formatting adjustments.
> > > > >>
> > > > >> The primary focus of the conversation is the proposed 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-03 Thread Micah Kornfield
https://stackoverflow.com/questions/61505068/is-interval-1-day-always-equal-to-interval-24-hours
comes up when doing a web search for this.

On Thu, Jul 3, 2025 at 10:39 AM Raphael Taylor-Davies
 wrote:

> I could be mistaken, but I seem to remember ANSI SQL doesn't have
> timezones, and therefore as far as it is concerned days can only have 24
> hours. Whether this assumption should be preserved in databases that
> support timezones though...
>
> On Thu, 3 Jul 2025, 18:32 Micah Kornfield,  wrote:
>
> > >
> > > Putting this to one side, I think the proposed DayTimeInterval still
> > > needs a separate day component in order to be SQL compliant, as days
> may
> > > not have 24 hours due to daylight savings time. I think what is being
> > > suggested might be better described as a duration type.
> >
> >
> > This has come up a few times.  It seems the SQL spec defines 1 day as
> > exactly 24 hours (86400) seconds for the purpose of intervals.  So yes it
> > is in fact a duration.  Postgres and BigQuery seem to be the two SQL
> > systems I'm aware of that treat day components in the "calendar" sense
> > instead of the duration sense.
> >
> > I wonder if people would be more comfortable not calling it DayTime
> > Interval and instead calling it a duration.  From the perspective of
> > arrow<->parquet interop since there is already a Nanosecond duration,
> > perhaps we should jump to Picoseconds and use int128 which I think would
> > satisfy the SQL requirements as well or allow for the fact that
> > Parquet's duration nanoseconds could potentially overflow Arrow's
> duration
> > seconds?
> >
> > Thanks,
> > Micah
> >
> > On Thu, Jul 3, 2025 at 9:22 AM Raphael Taylor-Davies
> >  wrote:
> >
> > > Hi,
> > >
> > > I may be misunderstanding something, but it appears that the motivation
> > > for this effort is that the current interval type represents a superset
> > > of the functionality required by ANSI SQL, and therefore can cause
> > > compatibility problems for some databases that only support the minimum
> > > required by ANSI SQL?
> > >
> > > In particular the parquet Interval (along with Arrow's MonthDayNano and
> > > postgres' interval) encode a number of months, days and some seconds in
> > > a single unified interval type, whereas the SQL standard instead
> defines
> > > two interval types - one consisting of a combination of years and
> > > months, and another days and some seconds quantity.
> > >
> > > Whilst I can see that bifurcating the parquet interval types to match
> > > the minimum required by the SQL standard might help those systems with
> > > such bifurcated interval types, it will be a net negative for those
> > > systems that instead have a unified interval type. I therefore suspect
> > > this will end up being a repeat of the ongoing Int96 saga, especially
> as
> > > IMO having a unified interval representation is a significant UX
> > > improvement whilst also providing strictly more functionality. I wonder
> > > if instead it might be better to define some mapping that can be used
> by
> > > systems with bifurcated interval types - perhaps as a struct column
> > > consisting of the two components? This would avoid an interminable
> > > migration period, whilst also not representing a loss of functionality
> > > or ergonomics for existing workloads.
> > >
> > > Putting this to one side, I think the proposed DayTimeInterval still
> > > needs a separate day component in order to be SQL compliant, as days
> may
> > > not have 24 hours due to daylight savings time. I think what is being
> > > suggested might be better described as a duration type.
> > >
> > > Kind Regards,
> > >
> > > Raphael
> > >
> > > On 03/07/2025 16:01, Felipe Oliveira Carvalho wrote:
> > > > Hi,
> > > >
> > > > I recently took the time to understand MonthDayNano better and it's
> not
> > > as
> > > > crazy as my first impression of it.
> > > >
> > > > I think we could solve many of the problems you're trying to solve by
> > > > embracing it. Replies inline:
> > > >
> > > > On Tue, Jul 1, 2025 at 2:56 AM yun zou 
> > > wrote:
> > > >
> > > >> Hi Team,
> > > >>
> > > >> Resending the previous email about the Interval Type discussion from
> > the
> > > >> last Parquet community sync, with some formatting adjustments.
> > > >>
> > > >> The primary focus of the conversation is the proposed INTERVAL
> type's
> > > >> *compatibility
> > > >> with Apache Arrow*. Several key issues have been raised:
> > > >>
> > > >> 1. *Is there a more descriptive name for DayTimeInterval?*
> > > >> While the name DayTimeInterval closely follows the SQL standard and
> > > matches
> > > >> naming conventions used by most engines, some suggest that a name
> > > >> emphasizing precision—such as *DayNanoInterval*—might provide better
> > > >> clarity.
> > > >>
> > > >> 2. *Should we consider representing DayTimeInterval using Arrow's
> > > >> MonthDayNano?*
> > > >> Mapping DayTimeInterval to Arrow's MonthDayNano type is problematic
> > due
> > > to

Re: [Discussion] Follow up discussion for Interval Type

2025-07-03 Thread Raphael Taylor-Davies
I could be mistaken, but I seem to remember ANSI SQL doesn't have
timezones, and therefore as far as it is concerned days can only have 24
hours. Whether this assumption should be preserved in databases that
support timezones though...

On Thu, 3 Jul 2025, 18:32 Micah Kornfield,  wrote:

> >
> > Putting this to one side, I think the proposed DayTimeInterval still
> > needs a separate day component in order to be SQL compliant, as days may
> > not have 24 hours due to daylight savings time. I think what is being
> > suggested might be better described as a duration type.
>
>
> This has come up a few times.  It seems the SQL spec defines 1 day as
> exactly 24 hours (86400) seconds for the purpose of intervals.  So yes it
> is in fact a duration.  Postgres and BigQuery seem to be the two SQL
> systems I'm aware of that treat day components in the "calendar" sense
> instead of the duration sense.
>
> I wonder if people would be more comfortable not calling it DayTime
> Interval and instead calling it a duration.  From the perspective of
> arrow<->parquet interop since there is already a Nanosecond duration,
> perhaps we should jump to Picoseconds and use int128 which I think would
> satisfy the SQL requirements as well or allow for the fact that
> Parquet's duration nanoseconds could potentially overflow Arrow's duration
> seconds?
>
> Thanks,
> Micah
>
> On Thu, Jul 3, 2025 at 9:22 AM Raphael Taylor-Davies
>  wrote:
>
> > Hi,
> >
> > I may be misunderstanding something, but it appears that the motivation
> > for this effort is that the current interval type represents a superset
> > of the functionality required by ANSI SQL, and therefore can cause
> > compatibility problems for some databases that only support the minimum
> > required by ANSI SQL?
> >
> > In particular the parquet Interval (along with Arrow's MonthDayNano and
> > postgres' interval) encode a number of months, days and some seconds in
> > a single unified interval type, whereas the SQL standard instead defines
> > two interval types - one consisting of a combination of years and
> > months, and another days and some seconds quantity.
> >
> > Whilst I can see that bifurcating the parquet interval types to match
> > the minimum required by the SQL standard might help those systems with
> > such bifurcated interval types, it will be a net negative for those
> > systems that instead have a unified interval type. I therefore suspect
> > this will end up being a repeat of the ongoing Int96 saga, especially as
> > IMO having a unified interval representation is a significant UX
> > improvement whilst also providing strictly more functionality. I wonder
> > if instead it might be better to define some mapping that can be used by
> > systems with bifurcated interval types - perhaps as a struct column
> > consisting of the two components? This would avoid an interminable
> > migration period, whilst also not representing a loss of functionality
> > or ergonomics for existing workloads.
> >
> > Putting this to one side, I think the proposed DayTimeInterval still
> > needs a separate day component in order to be SQL compliant, as days may
> > not have 24 hours due to daylight savings time. I think what is being
> > suggested might be better described as a duration type.
> >
> > Kind Regards,
> >
> > Raphael
> >
> > On 03/07/2025 16:01, Felipe Oliveira Carvalho wrote:
> > > Hi,
> > >
> > > I recently took the time to understand MonthDayNano better and it's not
> > as
> > > crazy as my first impression of it.
> > >
> > > I think we could solve many of the problems you're trying to solve by
> > > embracing it. Replies inline:
> > >
> > > On Tue, Jul 1, 2025 at 2:56 AM yun zou 
> > wrote:
> > >
> > >> Hi Team,
> > >>
> > >> Resending the previous email about the Interval Type discussion from
> the
> > >> last Parquet community sync, with some formatting adjustments.
> > >>
> > >> The primary focus of the conversation is the proposed INTERVAL type's
> > >> *compatibility
> > >> with Apache Arrow*. Several key issues have been raised:
> > >>
> > >> 1. *Is there a more descriptive name for DayTimeInterval?*
> > >> While the name DayTimeInterval closely follows the SQL standard and
> > matches
> > >> naming conventions used by most engines, some suggest that a name
> > >> emphasizing precision—such as *DayNanoInterval*—might provide better
> > >> clarity.
> > >>
> > >> 2. *Should we consider representing DayTimeInterval using Arrow's
> > >> MonthDayNano?*
> > >> Mapping DayTimeInterval to Arrow's MonthDayNano type is problematic
> due
> > to
> > >> semantic differences:
> > >>
> > >> -  MonthDayNano combines both calendar-based and duration-based
> > >> components, whereas DayTimeInterval represents a pure duration.
> > >>
> > > Month and Day components actually allow the SQL engine to delay caring
> > > about calendars when parsing interval literals:
> > >
> > >  INTERVAL '2-11 28' YEAR TO DAY
> > >
> > > month = 2 * 12 + 11. (there are no leap 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-03 Thread Micah Kornfield
>
> Putting this to one side, I think the proposed DayTimeInterval still
> needs a separate day component in order to be SQL compliant, as days may
> not have 24 hours due to daylight savings time. I think what is being
> suggested might be better described as a duration type.


This has come up a few times.  It seems the SQL spec defines 1 day as
exactly 24 hours (86400) seconds for the purpose of intervals.  So yes it
is in fact a duration.  Postgres and BigQuery seem to be the two SQL
systems I'm aware of that treat day components in the "calendar" sense
instead of the duration sense.

I wonder if people would be more comfortable not calling it DayTime
Interval and instead calling it a duration.  From the perspective of
arrow<->parquet interop since there is already a Nanosecond duration,
perhaps we should jump to Picoseconds and use int128 which I think would
satisfy the SQL requirements as well or allow for the fact that
Parquet's duration nanoseconds could potentially overflow Arrow's duration
seconds?

Thanks,
Micah

On Thu, Jul 3, 2025 at 9:22 AM Raphael Taylor-Davies
 wrote:

> Hi,
>
> I may be misunderstanding something, but it appears that the motivation
> for this effort is that the current interval type represents a superset
> of the functionality required by ANSI SQL, and therefore can cause
> compatibility problems for some databases that only support the minimum
> required by ANSI SQL?
>
> In particular the parquet Interval (along with Arrow's MonthDayNano and
> postgres' interval) encode a number of months, days and some seconds in
> a single unified interval type, whereas the SQL standard instead defines
> two interval types - one consisting of a combination of years and
> months, and another days and some seconds quantity.
>
> Whilst I can see that bifurcating the parquet interval types to match
> the minimum required by the SQL standard might help those systems with
> such bifurcated interval types, it will be a net negative for those
> systems that instead have a unified interval type. I therefore suspect
> this will end up being a repeat of the ongoing Int96 saga, especially as
> IMO having a unified interval representation is a significant UX
> improvement whilst also providing strictly more functionality. I wonder
> if instead it might be better to define some mapping that can be used by
> systems with bifurcated interval types - perhaps as a struct column
> consisting of the two components? This would avoid an interminable
> migration period, whilst also not representing a loss of functionality
> or ergonomics for existing workloads.
>
> Putting this to one side, I think the proposed DayTimeInterval still
> needs a separate day component in order to be SQL compliant, as days may
> not have 24 hours due to daylight savings time. I think what is being
> suggested might be better described as a duration type.
>
> Kind Regards,
>
> Raphael
>
> On 03/07/2025 16:01, Felipe Oliveira Carvalho wrote:
> > Hi,
> >
> > I recently took the time to understand MonthDayNano better and it's not
> as
> > crazy as my first impression of it.
> >
> > I think we could solve many of the problems you're trying to solve by
> > embracing it. Replies inline:
> >
> > On Tue, Jul 1, 2025 at 2:56 AM yun zou 
> wrote:
> >
> >> Hi Team,
> >>
> >> Resending the previous email about the Interval Type discussion from the
> >> last Parquet community sync, with some formatting adjustments.
> >>
> >> The primary focus of the conversation is the proposed INTERVAL type's
> >> *compatibility
> >> with Apache Arrow*. Several key issues have been raised:
> >>
> >> 1. *Is there a more descriptive name for DayTimeInterval?*
> >> While the name DayTimeInterval closely follows the SQL standard and
> matches
> >> naming conventions used by most engines, some suggest that a name
> >> emphasizing precision—such as *DayNanoInterval*—might provide better
> >> clarity.
> >>
> >> 2. *Should we consider representing DayTimeInterval using Arrow's
> >> MonthDayNano?*
> >> Mapping DayTimeInterval to Arrow's MonthDayNano type is problematic due
> to
> >> semantic differences:
> >>
> >> -  MonthDayNano combines both calendar-based and duration-based
> >> components, whereas DayTimeInterval represents a pure duration.
> >>
> > Month and Day components actually allow the SQL engine to delay caring
> > about calendars when parsing interval literals:
> >
> >  INTERVAL '2-11 28' YEAR TO DAY
> >
> > month = 2 * 12 + 11. (there are no leap months, so converting from years
> to
> > month is easy)
> > day = 28
> > nanos = 0
> >
> > If you get an interval/duration that is a single integer (as in the
> number
> > of nanoseconds), you can leave month and day set to 0. The annoying
> > limitation is that a 64-bit nanos field can't represent 10K years. How
> else
> > would you turn that weird SQL interval literal into a single integer
> > duration? Would you assume a year is 365 days?
> >
> > This is the internal representation of intervals 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-03 Thread Raphael Taylor-Davies

Hi,

I may be misunderstanding something, but it appears that the motivation 
for this effort is that the current interval type represents a superset 
of the functionality required by ANSI SQL, and therefore can cause 
compatibility problems for some databases that only support the minimum 
required by ANSI SQL?


In particular the parquet Interval (along with Arrow's MonthDayNano and 
postgres' interval) encode a number of months, days and some seconds in 
a single unified interval type, whereas the SQL standard instead defines 
two interval types - one consisting of a combination of years and 
months, and another days and some seconds quantity.


Whilst I can see that bifurcating the parquet interval types to match 
the minimum required by the SQL standard might help those systems with 
such bifurcated interval types, it will be a net negative for those 
systems that instead have a unified interval type. I therefore suspect 
this will end up being a repeat of the ongoing Int96 saga, especially as 
IMO having a unified interval representation is a significant UX 
improvement whilst also providing strictly more functionality. I wonder 
if instead it might be better to define some mapping that can be used by 
systems with bifurcated interval types - perhaps as a struct column 
consisting of the two components? This would avoid an interminable 
migration period, whilst also not representing a loss of functionality 
or ergonomics for existing workloads.


Putting this to one side, I think the proposed DayTimeInterval still 
needs a separate day component in order to be SQL compliant, as days may 
not have 24 hours due to daylight savings time. I think what is being 
suggested might be better described as a duration type.


Kind Regards,

Raphael

On 03/07/2025 16:01, Felipe Oliveira Carvalho wrote:

Hi,

I recently took the time to understand MonthDayNano better and it's not as
crazy as my first impression of it.

I think we could solve many of the problems you're trying to solve by
embracing it. Replies inline:

On Tue, Jul 1, 2025 at 2:56 AM yun zou  wrote:


Hi Team,

Resending the previous email about the Interval Type discussion from the
last Parquet community sync, with some formatting adjustments.

The primary focus of the conversation is the proposed INTERVAL type's
*compatibility
with Apache Arrow*. Several key issues have been raised:

1. *Is there a more descriptive name for DayTimeInterval?*
While the name DayTimeInterval closely follows the SQL standard and matches
naming conventions used by most engines, some suggest that a name
emphasizing precision—such as *DayNanoInterval*—might provide better
clarity.

2. *Should we consider representing DayTimeInterval using Arrow's
MonthDayNano?*
Mapping DayTimeInterval to Arrow's MonthDayNano type is problematic due to
semantic differences:

-  MonthDayNano combines both calendar-based and duration-based
components, whereas DayTimeInterval represents a pure duration.


Month and Day components actually allow the SQL engine to delay caring
about calendars when parsing interval literals:

 INTERVAL '2-11 28' YEAR TO DAY

month = 2 * 12 + 11. (there are no leap months, so converting from years to
month is easy)
day = 28
nanos = 0

If you get an interval/duration that is a single integer (as in the number
of nanoseconds), you can leave month and day set to 0. The annoying
limitation is that a 64-bit nanos field can't represent 10K years. How else
would you turn that weird SQL interval literal into a single integer
duration? Would you assume a year is 365 days?

This is the internal representation of intervals in PostgreSQL. It follows
the same structure as MonthDayNano: a 64-bit offset and 32-bit days and
months. This has the nice feature of aligning nicely to 8 bytes without
padding and still not requiring 128-bit math for operations.

/*
  * Storage format for type interval.
  */
typedef struct {
 TimeOffset time; /* all time units other than days, months and years */

  int32 day; /* days, after time for alignment */
  int32 month; /* months and years, after time for alignment */
} Interval;

- MonthDayNano allows mixed signs across components (e.g., positive

months and negative days), which complicates comparison and evaluation.


Yes, but adding more types to Arrow also complicates engines and
implementations.

Adding month and days to a timestamp wouldn't be so hard if timestamps also
stored the number of months and days since an epoch, but they are usually a
single value (millis, micros, nanos) since an epoch. Couldn't an argument
be made that any SQL system already needs to convert between single-integer
timestamps and -MM-DD HH:MM:SS literals, so this operation is not that
hard to support?

Complicated expressions involving timestamps and intervals could be
evaluated by converting timestamps to MonthDayNano durations since epoch
making every value become a duration, then at the end convert the duration
since 

Re: [Discussion] Follow up discussion for Interval Type

2025-07-03 Thread Felipe Oliveira Carvalho
Hi,

I recently took the time to understand MonthDayNano better and it's not as
crazy as my first impression of it.

I think we could solve many of the problems you're trying to solve by
embracing it. Replies inline:

On Tue, Jul 1, 2025 at 2:56 AM yun zou  wrote:

> Hi Team,
>
> Resending the previous email about the Interval Type discussion from the
> last Parquet community sync, with some formatting adjustments.
>
> The primary focus of the conversation is the proposed INTERVAL type's
> *compatibility
> with Apache Arrow*. Several key issues have been raised:
>
> 1. *Is there a more descriptive name for DayTimeInterval?*
> While the name DayTimeInterval closely follows the SQL standard and matches
> naming conventions used by most engines, some suggest that a name
> emphasizing precision—such as *DayNanoInterval*—might provide better
> clarity.
>
> 2. *Should we consider representing DayTimeInterval using Arrow's
> MonthDayNano?*
> Mapping DayTimeInterval to Arrow's MonthDayNano type is problematic due to
> semantic differences:
>
>-  MonthDayNano combines both calendar-based and duration-based
>components, whereas DayTimeInterval represents a pure duration.
>

Month and Day components actually allow the SQL engine to delay caring
about calendars when parsing interval literals:

INTERVAL '2-11 28' YEAR TO DAY

month = 2 * 12 + 11. (there are no leap months, so converting from years to
month is easy)
day = 28
nanos = 0

If you get an interval/duration that is a single integer (as in the number
of nanoseconds), you can leave month and day set to 0. The annoying
limitation is that a 64-bit nanos field can't represent 10K years. How else
would you turn that weird SQL interval literal into a single integer
duration? Would you assume a year is 365 days?

This is the internal representation of intervals in PostgreSQL. It follows
the same structure as MonthDayNano: a 64-bit offset and 32-bit days and
months. This has the nice feature of aligning nicely to 8 bytes without
padding and still not requiring 128-bit math for operations.

/*
 * Storage format for type interval.
 */
typedef struct {
TimeOffset time; /* all time units other than days, months and years */

 int32 day; /* days, after time for alignment */
 int32 month; /* months and years, after time for alignment */
} Interval;

   - MonthDayNano allows mixed signs across components (e.g., positive
>months and negative days), which complicates comparison and evaluation.
>

Yes, but adding more types to Arrow also complicates engines and
implementations.

Adding month and days to a timestamp wouldn't be so hard if timestamps also
stored the number of months and days since an epoch, but they are usually a
single value (millis, micros, nanos) since an epoch. Couldn't an argument
be made that any SQL system already needs to convert between single-integer
timestamps and -MM-DD HH:MM:SS literals, so this operation is not that
hard to support?

Complicated expressions involving timestamps and intervals could be
evaluated by converting timestamps to MonthDayNano durations since epoch
making every value become a duration, then at the end convert the duration
since epoch to a single-integer timestamp. Given how SQL literals are, I
don't see how operations on these values can be correct without these
concerns being taken into account.


> Given these differences, MonthDayNano is not a suitable candidate for
> representing DayTimeInterval and *we recommend not mapping DayTimeInterval
> to Arrow's MonthDayNano*.
>
> 3.* Memory Footprint: Is 16 bytes necessary for DayTimeInterval? *
>
>- Some engines (e.g., Spark, Trino) represent DayTimeInterval using only
>8 bytes, while others (like Oracle and Snowflake) support a wider range,
>potentially requiring more than 8 bytes. Additionally, there is
> interest in
>future support for higher precision, such as picoseconds, which would
> also
>demand a larger footprint.
>- One proposal is to parameterize the size or precision, allowing
>engines to define their own representations. However, this approach
>introduces complexity and makes standardization difficult. A fixed-size
>format that provides enough range for most use cases is considered more
>robust.
>- Several alternative strategies have been proposed:
>1. Use a 10-byte array, which is likely sufficient for all current
>engine requirements.
>2. Use a 16-byte array now, with the option to evolve it into a
>standardized int128 in the future.
>3. Start with an int64 representation, and plan for a future transition
>to int128, updating related types such as timestamps and intervals in
>parallel.
>
> Looking forward to hearing your thoughts on the above questions!
>
> Link to the proposal:
>
> https://docs.google.com/document/d/12ghQxWxyAhSQeZyy0IWiwJ02gTqFOgfYm8x851HZFLk/edit?tab=t.0
>
> Link to the PR: https://github.com/apache/parquet-format/pull/496/files
>
> Best