diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/temporal/DateTimeFunction.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/temporal/DateTimeFunction.java index 1168304a5e971..756dd17f24e08 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/temporal/DateTimeFunction.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/proc/temporal/DateTimeFunction.java @@ -76,7 +76,7 @@ protected DateTimeValue build( MapValue map, Supplier defaultZone ) @Override protected DateTimeValue select( AnyValue from, Supplier defaultZone ) { - throw new UnsupportedOperationException( ); + return DateTimeValue.select( from, defaultZone ); } @Override diff --git a/community/values/src/main/java/org/neo4j/values/StructureBuilder.java b/community/values/src/main/java/org/neo4j/values/StructureBuilder.java index a19701c750f52..0eb64c55ff16e 100644 --- a/community/values/src/main/java/org/neo4j/values/StructureBuilder.java +++ b/community/values/src/main/java/org/neo4j/values/StructureBuilder.java @@ -38,7 +38,7 @@ static T build( StructureBuilder builder, Iterable entry : entries ) { - builder.add( entry.getKey(), entry.getValue() ); + builder = builder.add( entry.getKey(), entry.getValue() ); } return builder.build(); } diff --git a/community/values/src/main/java/org/neo4j/values/storable/DateTimeValue.java b/community/values/src/main/java/org/neo4j/values/storable/DateTimeValue.java index bc3fab7b1d4f5..bafce85cc9cd3 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/DateTimeValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/DateTimeValue.java @@ -141,6 +141,11 @@ public static DateTimeValue build( MapValue map, Supplier defaultZone ) return StructureBuilder.build( builder( defaultZone ), map ); } + public static DateTimeValue select( AnyValue from, Supplier defaultZone ) + { + return builder( defaultZone ).selectDateTime( from ); + } + public static DateTimeValue truncate( TemporalUnit unit, TemporalValue input, @@ -150,7 +155,7 @@ public static DateTimeValue truncate( throw new UnsupportedOperationException( "not implemented" ); } - static StructureBuilder builder( Supplier defaultZone ) + static DateTimeBuilder builder( Supplier defaultZone ) { return new DateTimeBuilder( defaultZone ) { @@ -161,34 +166,81 @@ static StructureBuilder builder( Supplier defaul @Override public DateTimeValue buildInternal() { + boolean selectingDate = fields.containsKey( Field.date ); + boolean selectingTime = fields.containsKey( Field.time ); + boolean selectingDateTime = fields.containsKey( Field.datetime ); ZonedDateTime result; - if ( fields.containsKey( Field.time ) || fields.containsKey( Field.date ) || fields.containsKey( Field.datetime ) ) + if ( selectingDateTime ) { -// AnyValue time = fields.get( Field.time ); -// if ( !(time instanceof TemporalValue) ) -// { -// throw new IllegalArgumentException( String.format( "Cannot construct local date time from: %s", time ) ); -// } - // TODO select date, time, or both - throw new UnsupportedOperationException(); + AnyValue dtField = fields.get( Field.datetime ); + if ( !(dtField instanceof TemporalValue) ) + { + throw new IllegalArgumentException( String.format( "Cannot construct date time from: %s", dtField ) ); + } + TemporalValue dt = (TemporalValue) dtField; + OffsetTime timePart = dt.getTimePart( defaultZone ); + result = ZonedDateTime.of( dt.getDatePart(), timePart.toLocalTime(), timePart.getOffset() ); } - else if ( fields.containsKey( Field.week ) ) + else if ( selectingTime || selectingDate ) { - // Be sure to be in the start of the week based year (which can be later than 1st Jan) - result = defaulZonedDateTime.with( IsoFields.WEEK_BASED_YEAR, - safeCastIntegral( Field.year.name(), fields.get( Field.year ), Field.year.defaultValue ) ).with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, - 1 ).with( ChronoField.DAY_OF_WEEK, 1 ); + OffsetTime time; + if ( selectingTime ) + { + AnyValue timeField = fields.get( Field.time ); + if ( !(timeField instanceof TemporalValue) ) + { + throw new IllegalArgumentException( String.format( "Cannot construct local time from: %s", timeField ) ); + } + TemporalValue t = (TemporalValue) timeField; + time = t.getTimePart( defaultZone ); + } + else + { + time = TimeValue.defaultTime( timezone() ); + } + LocalDate date; + if ( selectingDate ) + { + AnyValue dateField = fields.get( Field.date ); + if ( !(dateField instanceof TemporalValue) ) + { + throw new IllegalArgumentException( String.format( "Cannot construct date from: %s", dateField ) ); + } + TemporalValue t = (TemporalValue) dateField; + date = t.getDatePart(); + } + else + { + date = DateValue.DEFAULT_CALENDER_DATE; + } + result = ZonedDateTime.of( date, time.toLocalTime(), time.getOffset() ); } else { result = defaulZonedDateTime; } + if ( fields.containsKey( Field.week ) && !selectingDate && !selectingDateTime ) + { + // Be sure to be in the start of the week based year (which can be later than 1st Jan) + result = result + .with( IsoFields.WEEK_BASED_YEAR, safeCastIntegral( Field.year.name(), fields.get( Field.year ), + Field.year.defaultValue ) ) + .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 ) + .with( ChronoField.DAY_OF_WEEK, 1 ); + } + result = assignAllFields( result ); if ( timezone != null ) { - // TODO this will be different when selecting - result = result.withZoneSameLocal( timezone() ); + if ( selectingTime || selectingDateTime ) + { + result = result.withZoneSameInstant( timezone() ); + } + else + { + result = result.withZoneSameLocal( timezone() ); + } } return datetime( result ); } diff --git a/community/values/src/main/java/org/neo4j/values/storable/DateValue.java b/community/values/src/main/java/org/neo4j/values/storable/DateValue.java index fb8d9f11009f6..efb26a3f2bf9b 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/DateValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/DateValue.java @@ -377,6 +377,8 @@ private static LocalDate localQuarterDate( int year, int quarter, int dayOfQuart .with( IsoFields.DAY_OF_QUARTER, dayOfQuarter ); } + static final LocalDate DEFAULT_CALENDER_DATE = LocalDate.of( Field.year.defaultValue, Field.month.defaultValue, Field.day.defaultValue ); + private static class DateBuilder extends Builder { DateBuilder( Supplier defaultZone ) @@ -406,8 +408,6 @@ private LocalDate getDateOf( org.neo4j.values.AnyValue temporal ) throw new IllegalArgumentException( String.format( "Cannot construct date from: %s", temporal ) ); } - private final LocalDate defaulCalenderDate = LocalDate.of( Field.year.defaultValue, Field.month.defaultValue, Field.day.defaultValue ); - @Override public DateValue buildInternal() { @@ -419,7 +419,7 @@ public DateValue buildInternal() else if ( fields.containsKey( Field.week ) ) { // Be sure to be in the start of the week based year (which can be later than 1st Jan) - result = defaulCalenderDate + result = DEFAULT_CALENDER_DATE .with( IsoFields.WEEK_BASED_YEAR, safeCastIntegral( Field.year.name(), fields.get( Field.year ), Field.year.defaultValue ) ) .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 ) @@ -427,7 +427,7 @@ else if ( fields.containsKey( Field.week ) ) } else { - result = defaulCalenderDate; + result = DEFAULT_CALENDER_DATE; } result = assignAllFields( result ); return date( result ); diff --git a/community/values/src/main/java/org/neo4j/values/storable/LocalDateTimeValue.java b/community/values/src/main/java/org/neo4j/values/storable/LocalDateTimeValue.java index a0c3a73b798ab..d5c311a25c843 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/LocalDateTimeValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/LocalDateTimeValue.java @@ -119,41 +119,80 @@ public static LocalDateTimeValue truncate( throw new UnsupportedOperationException( "not implemented" ); } + static final LocalDateTime DEFAULT_LOCAL_DATE_TIME = + LocalDateTime.of( Field.year.defaultValue, Field.month.defaultValue, Field.day.defaultValue, Field.hour.defaultValue, + Field.minute.defaultValue ); + static DateTimeValue.DateTimeBuilder builder( Supplier defaultZone ) { return new DateTimeValue.DateTimeBuilder( defaultZone ) { - private final LocalDateTime defaulLocalDateTime = - LocalDateTime.of( Field.year.defaultValue, Field.month.defaultValue, Field.day.defaultValue, Field.hour.defaultValue, - Field.minute.defaultValue ); - @Override public LocalDateTimeValue buildInternal() { + boolean selectingDate = fields.containsKey( Field.date ); + boolean selectingTime = fields.containsKey( Field.time ); + boolean selectingDateTime = fields.containsKey( Field.datetime ); LocalDateTime result; - if ( fields.containsKey( Field.time ) || fields.containsKey( Field.date ) || fields.containsKey( Field.datetime ) ) + if ( selectingDateTime ) + { + AnyValue dtField = fields.get( Field.datetime ); + if ( !(dtField instanceof TemporalValue) ) + { + throw new IllegalArgumentException( String.format( "Cannot construct local date time from: %s", dtField ) ); + } + TemporalValue dt = (TemporalValue) dtField; + result = LocalDateTime.of( dt.getDatePart(), dt.getLocalTimePart() ); + } + else if ( selectingTime || selectingDate ) { -// AnyValue time = fields.get( Field.time ); -// if ( !(time instanceof TemporalValue) ) -// { -// throw new IllegalArgumentException( String.format( "Cannot construct local date time from: %s", time ) ); -// } - // TODO select date, time, or both - throw new UnsupportedOperationException( ); + LocalTime time; + if ( selectingTime ) + { + AnyValue timeField = fields.get( Field.time ); + if ( !(timeField instanceof TemporalValue) ) + { + throw new IllegalArgumentException( String.format( "Cannot construct local time from: %s", timeField ) ); + } + TemporalValue t = (TemporalValue) timeField; + time = t.getLocalTimePart(); + } + else + { + time = LocalTimeValue.DEFAULT_LOCAL_TIME; + } + LocalDate date; + if ( selectingDate ) + { + AnyValue dateField = fields.get( Field.date ); + if ( !(dateField instanceof TemporalValue) ) + { + throw new IllegalArgumentException( String.format( "Cannot construct date from: %s", dateField ) ); + } + TemporalValue t = (TemporalValue) dateField; + date = t.getDatePart(); + } + else + { + date = DateValue.DEFAULT_CALENDER_DATE; + } + + result = LocalDateTime.of( date, time ); } - else if ( fields.containsKey( Field.week ) ) + else + { + result = DEFAULT_LOCAL_DATE_TIME; + } + + if ( fields.containsKey( Field.week ) && !selectingDate && !selectingDateTime ) { // Be sure to be in the start of the week based year (which can be later than 1st Jan) - result = defaulLocalDateTime + result = result .with( IsoFields.WEEK_BASED_YEAR, safeCastIntegral( Field.year.name(), fields.get( Field.year ), Field.year.defaultValue ) ) .with( IsoFields.WEEK_OF_WEEK_BASED_YEAR, 1 ) .with( ChronoField.DAY_OF_WEEK, 1 ); } - else - { - result = defaulLocalDateTime; - } result = assignAllFields( result ); return localDateTime( result ); diff --git a/community/values/src/main/java/org/neo4j/values/storable/LocalTimeValue.java b/community/values/src/main/java/org/neo4j/values/storable/LocalTimeValue.java index ca15fa7c80a00..0ef97db64eeb7 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/LocalTimeValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/LocalTimeValue.java @@ -105,13 +105,12 @@ public static LocalTimeValue truncate( throw new UnsupportedOperationException( "not implemented" ); } + static final LocalTime DEFAULT_LOCAL_TIME = LocalTime.of( Field.hour.defaultValue, Field.minute.defaultValue ); + static TimeValue.TimeBuilder builder( Supplier defaultZone ) { return new TimeValue.TimeBuilder( defaultZone ) { - - private final LocalTime defaulLocalTime = LocalTime.of( Field.hour.defaultValue, Field.minute.defaultValue ); - @Override public LocalTimeValue buildInternal() { @@ -127,7 +126,7 @@ public LocalTimeValue buildInternal() } else { - result = defaulLocalTime; + result = DEFAULT_LOCAL_TIME; } result = assignAllFields( result ); diff --git a/community/values/src/main/java/org/neo4j/values/storable/TemporalValue.java b/community/values/src/main/java/org/neo4j/values/storable/TemporalValue.java index 1b20a93e4a2d4..2ca5ab2e6f9b7 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/TemporalValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/TemporalValue.java @@ -439,11 +439,15 @@ void assign( Builder builder, AnyValue value ) @Override void assign( Builder builder, AnyValue value ) { + if ( !builder.supportsDate() ) + { + throw new IllegalArgumentException( "Not supported: " + name() ); + } if ( builder.state == null ) { builder.state = new DateTimeBuilder(); } - builder.state.date( value ); + builder.state = builder.state.assign( this, value ); } @Override @@ -458,11 +462,15 @@ boolean isGroupSelector() @Override void assign( Builder builder, AnyValue value ) { + if ( !builder.supportsTime() ) + { + throw new IllegalArgumentException( "Not supported: " + name() ); + } if ( builder.state == null ) { builder.state = new DateTimeBuilder(); } - builder.state.time( value ); + builder.state = builder.state.assign( this, value ); } @Override @@ -477,14 +485,15 @@ boolean isGroupSelector() @Override void assign( Builder builder, AnyValue value ) { - if ( builder.state == null ) + if ( !builder.supportsDate() || !builder.supportsTime() ) { - builder.state = new DateTimeBuilder( value ); + throw new IllegalArgumentException( "Not supported: " + name() ); } - else + if ( builder.state == null ) { - throw new IllegalArgumentException( "Cannot select datetime when assigning other fields." ); + builder.state = new DateTimeBuilder( ); } + builder.state = builder.state.assign( this, value ); } @Override @@ -537,23 +546,23 @@ void assign( Builder builder, AnyValue value ) { builder.state = new DateTimeBuilder(); } - builder.state.assign( this, value ); + builder.state = builder.state.assign( this, value ); } } - private static final class DateTimeBuilder + private static class DateTimeBuilder { - private DateBuilder date; - private ConstructTime time; - private AnyValue datetime; + protected DateBuilder date; + protected ConstructTime time; DateTimeBuilder() { } - DateTimeBuilder( AnyValue datetime ) + DateTimeBuilder( DateBuilder date, ConstructTime time ) { - this.datetime = datetime; + this.date = date; + this.time = time; } void checkAssignments( boolean requiresDate ) @@ -579,26 +588,59 @@ void checkAssignments( boolean requiresDate ) } } - void assign( Field field, AnyValue value ) + DateTimeBuilder assign( Field field, AnyValue value ) { if ( field == Field.datetime ) { - if ( date != null ) - { - date = new ConstructDate( datetime ); - } - else - { - date.assign( field, value ); - } - if ( time != null ) + return new SelectDateTimeDTBuilder( date, time ); + } + else if ( field == Field.time || field == Field.date ) + { + return new SelectDateOrTimeDTBuilder( date, time ).assign( field, value ); + } + else if ( field.field.isDateBased() ) + { + if ( date == null ) { - time = new ConstructTime( datetime ); + date = new ConstructDate(); } - else + date = date.assign( field, value ); + } + else + { + if ( time == null ) { - time.assign( field, value ); + time = new ConstructTime(); } + time.assign( field, value ); + } + return this; + } + } + + private static class SelectDateTimeDTBuilder extends DateTimeBuilder + { + SelectDateTimeDTBuilder( DateBuilder date, ConstructTime time ) + { + super( date, time ); + } + + @Override + void checkAssignments( boolean requiresDate ) + { + // Nothing to do + } + + @Override + DateTimeBuilder assign( Field field, AnyValue value ) + { + if ( field == Field.date || field == Field.time ) + { + throw new IllegalArgumentException( field.name() + " cannot be selected together with datetime." ); + } + else if ( field == Field.datetime ) + { + throw new IllegalArgumentException( "cannot re-assign " + field ); } else if ( field.field.isDateBased() ) { @@ -616,24 +658,41 @@ else if ( field.field.isDateBased() ) } time.assign( field, value ); } + return this; } + } - void date( AnyValue date ) + private static class SelectDateOrTimeDTBuilder extends DateTimeBuilder + { + SelectDateOrTimeDTBuilder( DateBuilder date, ConstructTime time ) { - if ( this.date != null ) - { - throw new IllegalArgumentException( "cannot select date when also assigning date" ); - } - this.date = new ConstructDate( date ); + super( date, time ); } - void time( AnyValue time ) + @Override + DateTimeBuilder assign( Field field, AnyValue value ) { - if ( this.time != null ) + if ( field == Field.datetime ) { - throw new IllegalArgumentException( "cannot select time when also assigning time" ); + throw new IllegalArgumentException( field.name() + " cannot be selected together with date or time." ); } - this.time = new ConstructTime( time ); + else if ( field != Field.time && (field == Field.date || field.field.isDateBased()) ) + { + if ( date == null ) + { + date = new ConstructDate(); + } + date = date.assign( field, value ); + } + else + { + if ( time == null ) + { + time = new ConstructTime(); + } + time.assign( field, value ); + } + return this; } } @@ -660,11 +719,6 @@ private static final class ConstructTime { } - ConstructTime( AnyValue time ) - { - this.time = time; - } - void assign( Field field, AnyValue value ) { switch ( field ) @@ -690,6 +744,7 @@ void assign( Field field, AnyValue value ) case time: case datetime: time = assignment( field, time, value ); + break; default: throw new IllegalStateException( "Not a time field: " + field ); } diff --git a/community/values/src/main/java/org/neo4j/values/storable/TimeValue.java b/community/values/src/main/java/org/neo4j/values/storable/TimeValue.java index d8c1844b87e26..bdfe8a97cbb25 100644 --- a/community/values/src/main/java/org/neo4j/values/storable/TimeValue.java +++ b/community/values/src/main/java/org/neo4j/values/storable/TimeValue.java @@ -109,15 +109,17 @@ public static TimeValue truncate( throw new UnsupportedOperationException( "not implemented" ); } + static OffsetTime defaultTime( ZoneId zoneId ) + { + return OffsetTime.of( Field.hour.defaultValue, Field.minute.defaultValue, Field.second.defaultValue, Field.nanosecond.defaultValue, + ZoneOffset.of( zoneId.toString() ) ); + } + static TimeBuilder builder( Supplier defaultZone ) { return new TimeBuilder( defaultZone ) { - private final OffsetTime defaulTime = - OffsetTime.of( Field.hour.defaultValue, Field.minute.defaultValue, Field.second.defaultValue, Field.nanosecond.defaultValue, - ZoneOffset.of( timezone().toString() ) ); - @Override public TimeValue buildInternal() { @@ -134,7 +136,7 @@ public TimeValue buildInternal() } else { - result = defaulTime; + result = defaultTime( timezone() ); } result = assignAllFields( result ); diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-23.txt b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-23.txt index 1286eb83fceb6..76fdca220705c 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-23.txt +++ b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-23.txt @@ -66,10 +66,14 @@ Feature "UnwindAcceptance": Scenario "Pattern comprehension in unwind with hits" Feature "TemporalSelectAcceptance": Scenario "Should select date" Feature "TemporalSelectAcceptance": Scenario "Should select local time" Feature "TemporalSelectAcceptance": Scenario "Should select time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time 2" -Feature "TemporalSelectAcceptance": Scenario "Should select date time" -Feature "TemporalSelectAcceptance": Scenario "Should select date time 2" +Feature "TemporalSelectAcceptance": Scenario "Should select date into local date time" +Feature "TemporalSelectAcceptance": Scenario "Should select time into local date time" +Feature "TemporalSelectAcceptance": Scenario "Should select date and time into local date time" +Feature "TemporalSelectAcceptance": Scenario "Should select datetime into local date time" +Feature "TemporalSelectAcceptance": Scenario "Should select date into date time" +Feature "TemporalSelectAcceptance": Scenario "Should select time into date time" +Feature "TemporalSelectAcceptance": Scenario "Should select date and time into date time" +Feature "TemporalSelectAcceptance": Scenario "Should select datetime into date time" Feature "TemporalComparisonAcceptance": Scenario "Should compare dates" Feature "TemporalComparisonAcceptance": Scenario "Should compare local times" Feature "TemporalComparisonAcceptance": Scenario "Should compare times" diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-31.txt b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-31.txt index 70af8bd1b0d48..3f040d19b42e4 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-31.txt +++ b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-31.txt @@ -18,13 +18,6 @@ Feature "ReturnAcceptance": Scenario "LIMIT 0 should stop side effects" Feature "UnwindAcceptance": Scenario "Pattern comprehension in unwind with empty db" Feature "UnwindAcceptance": Scenario "Pattern comprehension in unwind with hits" -Feature "TemporalSelectAcceptance": Scenario "Should select date" -Feature "TemporalSelectAcceptance": Scenario "Should select local time" -Feature "TemporalSelectAcceptance": Scenario "Should select time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time 2" -Feature "TemporalSelectAcceptance": Scenario "Should select date time" -Feature "TemporalSelectAcceptance": Scenario "Should select date time 2" Feature "TemporalComparisonAcceptance": Scenario "Should compare dates" Feature "TemporalComparisonAcceptance": Scenario "Should compare local times" Feature "TemporalComparisonAcceptance": Scenario "Should compare times" diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-33.txt b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-33.txt index 02b6986c5cbc3..cccf5e6f68605 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-33.txt +++ b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/compatibility-33.txt @@ -8,13 +8,6 @@ Feature "ProcedureCallAcceptance": Scenario "In-query call to unknown procedure Feature "UnwindAcceptance": Scenario "Pattern comprehension in unwind with empty db" Feature "UnwindAcceptance": Scenario "Pattern comprehension in unwind with hits" -Feature "TemporalSelectAcceptance": Scenario "Should select date" -Feature "TemporalSelectAcceptance": Scenario "Should select local time" -Feature "TemporalSelectAcceptance": Scenario "Should select time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time 2" -Feature "TemporalSelectAcceptance": Scenario "Should select date time" -Feature "TemporalSelectAcceptance": Scenario "Should select date time 2" Feature "TemporalComparisonAcceptance": Scenario "Should compare dates" Feature "TemporalComparisonAcceptance": Scenario "Should compare local times" Feature "TemporalComparisonAcceptance": Scenario "Should compare times" diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-compiled.txt b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-compiled.txt index 71b4bfb374786..103a5e8c33809 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-compiled.txt +++ b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-compiled.txt @@ -201,14 +201,17 @@ Feature "VarLengthAcceptance": Scenario "Handles checking properties on relation Feature "VarLengthAcceptance": Scenario "Handles checking properties on relationships in multistep path - using ALL() function on path relationship properties" Feature "UnwindAcceptance": Scenario "Pattern comprehension in unwind with empty db" Feature "UnwindAcceptance": Scenario "Pattern comprehension in unwind with hits" - Feature "TemporalSelectAcceptance": Scenario "Should select date" Feature "TemporalSelectAcceptance": Scenario "Should select local time" Feature "TemporalSelectAcceptance": Scenario "Should select time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time 2" -Feature "TemporalSelectAcceptance": Scenario "Should select date time" -Feature "TemporalSelectAcceptance": Scenario "Should select date time 2" +Feature "TemporalSelectAcceptance": Scenario "Should select date into local date time" +Feature "TemporalSelectAcceptance": Scenario "Should select time into local date time" +Feature "TemporalSelectAcceptance": Scenario "Should select date and time into local date time" +Feature "TemporalSelectAcceptance": Scenario "Should select datetime into local date time" +Feature "TemporalSelectAcceptance": Scenario "Should select date into date time" +Feature "TemporalSelectAcceptance": Scenario "Should select time into date time" +Feature "TemporalSelectAcceptance": Scenario "Should select date and time into date time" +Feature "TemporalSelectAcceptance": Scenario "Should select datetime into date time" Feature "TemporalComparisonAcceptance": Scenario "Should compare dates" Feature "TemporalComparisonAcceptance": Scenario "Should compare local times" Feature "TemporalComparisonAcceptance": Scenario "Should compare times" diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-interpreted.txt b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-interpreted.txt index c48882b7d31d4..a8dd09ddc4a3b 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-interpreted.txt +++ b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-interpreted.txt @@ -3,13 +3,6 @@ Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure should Feature "ProcedureCallAcceptance": Scenario "Standalone call to unknown procedure should fail" Feature "ProcedureCallAcceptance": Scenario "In-query call to unknown procedure should fail" -Feature "TemporalSelectAcceptance": Scenario "Should select date" -Feature "TemporalSelectAcceptance": Scenario "Should select local time" -Feature "TemporalSelectAcceptance": Scenario "Should select time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time 2" -Feature "TemporalSelectAcceptance": Scenario "Should select date time" -Feature "TemporalSelectAcceptance": Scenario "Should select date time 2" Feature "TemporalComparisonAcceptance": Scenario "Should compare dates" Feature "TemporalComparisonAcceptance": Scenario "Should compare local times" Feature "TemporalComparisonAcceptance": Scenario "Should compare times" diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-slotted.txt b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-slotted.txt index a06a0ffea5491..93b2f51ec082b 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-slotted.txt +++ b/enterprise/cypher/acceptance-spec-suite/src/test/resources/blacklists/cost-slotted.txt @@ -2,13 +2,6 @@ Feature "ProcedureCallAcceptance": Scenario "Standalone call to procedure should Feature "ProcedureCallAcceptance": Scenario "Standalone call to unknown procedure should fail" Feature "ProcedureCallAcceptance": Scenario "In-query call to unknown procedure should fail" -Feature "TemporalSelectAcceptance": Scenario "Should select date" -Feature "TemporalSelectAcceptance": Scenario "Should select local time" -Feature "TemporalSelectAcceptance": Scenario "Should select time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time" -Feature "TemporalSelectAcceptance": Scenario "Should select local date time 2" -Feature "TemporalSelectAcceptance": Scenario "Should select date time" -Feature "TemporalSelectAcceptance": Scenario "Should select date time 2" Feature "TemporalComparisonAcceptance": Scenario "Should compare dates" Feature "TemporalComparisonAcceptance": Scenario "Should compare local times" Feature "TemporalComparisonAcceptance": Scenario "Should compare times" diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/resources/cypher/features/TemporalSelectAcceptance.feature b/enterprise/cypher/acceptance-spec-suite/src/test/resources/cypher/features/TemporalSelectAcceptance.feature index bdf745e83a3fa..41fb05c40916c 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/resources/cypher/features/TemporalSelectAcceptance.feature +++ b/enterprise/cypher/acceptance-spec-suite/src/test/resources/cypher/features/TemporalSelectAcceptance.feature @@ -24,15 +24,22 @@ Feature: TemporalSelectAcceptance Given an empty graph When executing query: """ - UNWIND [date({year:1984, month:10, day:11}), - localdatetime({year:1984, month:10, day:11, hour:12, minute:31, second:14, nanosecond: 645876123}), - datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as dd - RETURN date({date: dd}) as d, - date({date: dd, day: 28}) as d2, - date(dd) as d3 + UNWIND [date({year:1984, month:11, day:11}), + localdatetime({year:1984, month:11, day:11, hour:12, minute:31, second:14, nanosecond: 645876123}), + datetime({year:1984, month:11, day:11, hour:12, timezone: '+01:00'})] as dd + RETURN date(dd) as d1, + date({date: dd}) as d2, + date({date: dd, year: 28}) as d3, + date({date: dd, day: 28}) as d4, + date({date: dd, week: 1}) as d5, + date({date: dd, ordinalDay: 28}) as d6, + date({date: dd, quarter: 3}) as d7 """ Then the result should be, in order: - | d | d2 | d3 | + | d1 | d2 | d3 | d4 | d5 | d6 | d7 | + | '1984-11-11' | '1984-11-11' | '0028-11-11' | '1984-11-28' | '1984-01-08' | '1984-01-28' | '1984-08-11' | + | '1984-11-11' | '1984-11-11' | '0028-11-11' | '1984-11-28' | '1984-01-08' | '1984-01-28' | '1984-08-11' | + | '1984-11-11' | '1984-11-11' | '0028-11-11' | '1984-11-28' | '1984-01-08' | '1984-01-28' | '1984-08-11' | And no side effects Scenario: Should select local time @@ -43,12 +50,16 @@ Feature: TemporalSelectAcceptance time({hour:12, minute:31, second:14, microsecond: 645876, timezone: '+01:00'}), localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as dd - RETURN localtime({time:dd}) as d, - localtime({time:dd, second: 42}) as d2, - localtime(dd) as d3 + RETURN localtime(dd) as d1, + localtime({time:dd}) as d2, + localtime({time:dd, second: 42}) as d3 """ Then the result should be, in order: - | d | d2 | d3 | + | d1 | d2 | d3 | + | '12:31:14.645876123' | '12:31:14.645876123' | '12:31:42.645876123' | + | '12:31:14.645876' | '12:31:14.645876' | '12:31:42.645876' | + | '12:31:14.645' | '12:31:14.645' | '12:31:42.645' | + | '12:00' | '12:00' | '12:00:42' | And no side effects Scenario: Should select time @@ -59,17 +70,57 @@ Feature: TemporalSelectAcceptance time({hour:12, minute:31, second:14, microsecond: 645876, timezone: '+01:00'}), localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as dd - RETURN time({time:dd}) as d, - time({time:dd, timezone:'+05:00'}) as d2, - time({time:dd, second: 42}) as d3, - time({time:dd, second: 42, timezone:'+05:00'}) as d4, - time(dd) as d5 + RETURN time(dd) as d1, + time({time:dd}) as d2, + time({time:dd, timezone:'+05:00'}) as d3, + time({time:dd, second: 42}) as d4, + time({time:dd, second: 42, timezone:'+05:00'}) as d5 + """ + Then the result should be, in order: + | d1 | d2 | d3 | d4 | d5 | + | '12:31:14.645876123Z' | '12:31:14.645876123Z' | '17:31:14.645876123+05:00' | '12:31:42.645876123Z' | '17:31:42.645876123+05:00' | + | '12:31:14.645876+01:00' | '12:31:14.645876+01:00' | '16:31:14.645876+05:00' | '12:31:42.645876+01:00' | '16:31:42.645876+05:00' | + | '12:31:14.645Z' | '12:31:14.645Z' | '17:31:14.645+05:00' | '12:31:42.645Z' | '17:31:42.645+05:00' | + | '12:00+01:00' | '12:00+01:00' | '16:00+05:00' | '12:00:42+01:00' | '16:00:42+05:00' | + And no side effects + + Scenario: Should select date into local date time + Given an empty graph + When executing query: + """ + UNWIND [date({year:1984, month:10, day:11}), + localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), + datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as dd + RETURN localdatetime({date:dd, hour: 10, minute: 10, second: 10}) as d1, + localdatetime({date:dd, day: 28, hour: 10, minute: 10, second: 10}) as d2 + """ + Then the result should be, in order: + | d1 | d2 | + | '1984-10-11T10:10:10' | '1984-10-28T10:10:10' | + | '1984-03-07T10:10:10' | '1984-03-28T10:10:10' | + | '1984-10-11T10:10:10' | '1984-10-28T10:10:10' | + And no side effects + + Scenario: Should select time into local date time + Given an empty graph + When executing query: + """ + UNWIND [localtime({hour:12, minute:31, second:14, nanosecond: 645876123}), + time({hour:12, minute:31, second:14, microsecond: 645876, timezone: '+01:00'}), + localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), + datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as tt + RETURN localdatetime({year:1984, month:10, day:11, time:tt}) as d1, + localdatetime({year:1984, month:10, day:11, time:tt, second: 42}) as d2 """ Then the result should be, in order: - | d | d2 | d3 | d4 | d5| + | d1 | d2 | + | '1984-10-11T12:31:14.645876123' | '1984-10-11T12:31:42.645876123' | + | '1984-10-11T12:31:14.645876' | '1984-10-11T12:31:42.645876' | + | '1984-10-11T12:31:14.645' | '1984-10-11T12:31:42.645' | + | '1984-10-11T12:00' | '1984-10-11T12:00:42' | And no side effects - Scenario: Should select local date time + Scenario: Should select date and time into local date time Given an empty graph When executing query: """ @@ -80,28 +131,82 @@ Feature: TemporalSelectAcceptance time({hour:12, minute:31, second:14, microsecond: 645876, timezone: '+01:00'}), localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as tt - RETURN localdatetime({date:dd, time:tt}) as d, + RETURN localdatetime({date:dd, time:tt}) as d1, localdatetime({date:dd, time:tt, day: 28, second: 42}) as d2 """ Then the result should be, in order: - | d | d2 | + | d1 | d2 | + | '1984-10-11T12:31:14.645876123' | '1984-10-28T12:31:42.645876123' | + | '1984-10-11T12:31:14.645876' | '1984-10-28T12:31:42.645876' | + | '1984-10-11T12:31:14.645' | '1984-10-28T12:31:42.645' | + | '1984-10-11T12:00' | '1984-10-28T12:00:42' | + | '1984-03-07T12:31:14.645876123' | '1984-03-28T12:31:42.645876123' | + | '1984-03-07T12:31:14.645876' | '1984-03-28T12:31:42.645876' | + | '1984-03-07T12:31:14.645' | '1984-03-28T12:31:42.645' | + | '1984-03-07T12:00' | '1984-03-28T12:00:42' | + | '1984-10-11T12:31:14.645876123' | '1984-10-28T12:31:42.645876123' | + | '1984-10-11T12:31:14.645876' | '1984-10-28T12:31:42.645876' | + | '1984-10-11T12:31:14.645' | '1984-10-28T12:31:42.645' | + | '1984-10-11T12:00' | '1984-10-28T12:00:42' | And no side effects - Scenario: Should select local date time 2 + Scenario: Should select datetime into local date time Given an empty graph When executing query: """ UNWIND [localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as dd - RETURN localdatetime({datetime:dd}) as d, - localdatetime({datetime:dd, day: 28, second: 42}) as d2, - localdatetime(dd) as d3 + RETURN localdatetime(dd) as d1, + localdatetime({datetime:dd}) as d2, + localdatetime({datetime:dd, day: 28, second: 42}) as d3 """ Then the result should be, in order: - | d | d2 | d3 | + | d1 | d2 | d3 | + | '1984-03-07T12:31:14.645' | '1984-03-07T12:31:14.645' | '1984-03-28T12:31:42.645' | + | '1984-10-11T12:00' | '1984-10-11T12:00' | '1984-10-28T12:00:42' | And no side effects - Scenario: Should select date time + Scenario: Should select date into date time + Given an empty graph + When executing query: + """ + UNWIND [date({year:1984, month:10, day:11}), + localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), + datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as dd + RETURN datetime({date:dd, hour: 10, minute: 10, second: 10}) as d1, + datetime({date:dd, hour: 10, minute: 10, second: 10, timezone:'+05:00'}) as d2, + datetime({date:dd, day: 28, hour: 10, minute: 10, second: 10}) as d3, + datetime({date:dd, day: 28, hour: 10, minute: 10, second: 10, timezone:'+05:00'}) as d4 + """ + Then the result should be, in order: + | d1 | d2 | d3 | d4 | + | '1984-10-11T10:10:10Z' | '1984-10-11T10:10:10+05:00' | '1984-10-28T10:10:10Z' | '1984-10-28T10:10:10+05:00' | + | '1984-03-07T10:10:10Z' | '1984-03-07T10:10:10+05:00' | '1984-03-28T10:10:10Z' | '1984-03-28T10:10:10+05:00' | + | '1984-10-11T10:10:10Z' | '1984-10-11T10:10:10+05:00' | '1984-10-28T10:10:10Z' | '1984-10-28T10:10:10+05:00' | + And no side effects + + Scenario: Should select time into date time + Given an empty graph + When executing query: + """ + UNWIND [localtime({hour:12, minute:31, second:14, nanosecond: 645876123}), + time({hour:12, minute:31, second:14, microsecond: 645876, timezone: '+01:00'}), + localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), + datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as tt + RETURN datetime({year:1984, month:10, day:11, time:tt}) as d1, + datetime({year:1984, month:10, day:11, time:tt, timezone:'+05:00'}) as d2, + datetime({year:1984, month:10, day:11, time:tt, second: 42}) as d3, + datetime({year:1984, month:10, day:11, time:tt, second: 42, timezone:'+05:00'}) as d4 + """ + Then the result should be, in order: + | d1 | d2 | d3 | d4 | + | '1984-10-11T12:31:14.645876123Z' | '1984-10-11T17:31:14.645876123+05:00' | '1984-10-11T12:31:42.645876123Z' | '1984-10-11T17:31:42.645876123+05:00' | + | '1984-10-11T12:31:14.645876+01:00'| '1984-10-11T16:31:14.645876+05:00' | '1984-10-11T12:31:42.645876+01:00'| '1984-10-11T16:31:42.645876+05:00' | + | '1984-10-11T12:31:14.645Z' | '1984-10-11T17:31:14.645+05:00' | '1984-10-11T12:31:42.645Z' | '1984-10-11T17:31:42.645+05:00' | + | '1984-10-11T12:00+01:00' | '1984-10-11T16:00+05:00' | '1984-10-11T12:00:42+01:00' | '1984-10-11T16:00:42+05:00' | + And no side effects + + Scenario: Should select date and time into date time Given an empty graph When executing query: """ @@ -112,27 +217,42 @@ Feature: TemporalSelectAcceptance time({hour:12, minute:31, second:14, microsecond: 645876, timezone: '+01:00'}), localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as tt - RETURN datetime({date:dd, time:tt}) as d, + RETURN datetime({date:dd, time:tt}) as d1, datetime({date:dd, time:tt, timezone:'+05:00'}) as d2, datetime({date:dd, time:tt, day: 28, second: 42}) as d3, datetime({date:dd, time:tt, day: 28, second: 42, timezone:'+05:00'}) as d4 """ Then the result should be, in order: - | d | d2 | d3 | d4 | + | d1 | d2 | d3 | d4 | + | '1984-10-11T12:31:14.645876123Z' | '1984-10-11T17:31:14.645876123+05:00' | '1984-10-28T12:31:42.645876123Z' | '1984-10-28T17:31:42.645876123+05:00' | + | '1984-10-11T12:31:14.645876+01:00' | '1984-10-11T16:31:14.645876+05:00' | '1984-10-28T12:31:42.645876+01:00' | '1984-10-28T16:31:42.645876+05:00' | + | '1984-10-11T12:31:14.645Z' | '1984-10-11T17:31:14.645+05:00' | '1984-10-28T12:31:42.645Z' | '1984-10-28T17:31:42.645+05:00' | + | '1984-10-11T12:00+01:00' | '1984-10-11T16:00+05:00' | '1984-10-28T12:00:42+01:00' | '1984-10-28T16:00:42+05:00' | + | '1984-03-07T12:31:14.645876123Z' | '1984-03-07T17:31:14.645876123+05:00' | '1984-03-28T12:31:42.645876123Z' | '1984-03-28T17:31:42.645876123+05:00' | + | '1984-03-07T12:31:14.645876+01:00' | '1984-03-07T16:31:14.645876+05:00' | '1984-03-28T12:31:42.645876+01:00' | '1984-03-28T16:31:42.645876+05:00' | + | '1984-03-07T12:31:14.645Z' | '1984-03-07T17:31:14.645+05:00' | '1984-03-28T12:31:42.645Z' | '1984-03-28T17:31:42.645+05:00' | + | '1984-03-07T12:00+01:00' | '1984-03-07T16:00+05:00' | '1984-03-28T12:00:42+01:00' | '1984-03-28T16:00:42+05:00' | + | '1984-10-11T12:31:14.645876123Z' | '1984-10-11T17:31:14.645876123+05:00' | '1984-10-28T12:31:42.645876123Z' | '1984-10-28T17:31:42.645876123+05:00' | + | '1984-10-11T12:31:14.645876+01:00' | '1984-10-11T16:31:14.645876+05:00' | '1984-10-28T12:31:42.645876+01:00' | '1984-10-28T16:31:42.645876+05:00' | + | '1984-10-11T12:31:14.645Z' | '1984-10-11T17:31:14.645+05:00' | '1984-10-28T12:31:42.645Z' | '1984-10-28T17:31:42.645+05:00' | + | '1984-10-11T12:00+01:00' | '1984-10-11T16:00+05:00' | '1984-10-28T12:00:42+01:00' | '1984-10-28T16:00:42+05:00' | And no side effects - Scenario: Should select date time 2 + Scenario: Should select datetime into date time Given an empty graph When executing query: """ UNWIND [localdatetime({year:1984, week:10, dayOfWeek:3, hour:12, minute:31, second:14, millisecond: 645}), datetime({year:1984, month:10, day:11, hour:12, timezone: '+01:00'})] as dd - RETURN datetime({datetime:dd}) as d, - datetime({datetime:dd, day: 28, second: 42}) as d2, - datetime({datetime:dd, day: 28, second: 42}) as d3, - datetime({datetime:dd, day: 28, second: 42, timezone:'+05:00'}) as d4, - datetime(dd) as d5 + RETURN datetime(dd) as d1, + datetime({datetime:dd}) as d2, + datetime({datetime:dd, timezone:'+05:00'}) as d3, + datetime({datetime:dd, day: 28, second: 42}) as d4, + datetime({datetime:dd, day: 28, second: 42, timezone:'+05:00'}) as d5 + """ Then the result should be, in order: - | d | d2 | d3 | d4 | d5 | + | d1 | d2 | d3 | d4 | d5 | + | '1984-03-07T12:31:14.645Z' | '1984-03-07T12:31:14.645Z' | '1984-03-07T17:31:14.645+05:00' | '1984-03-28T12:31:42.645Z' | '1984-03-28T17:31:42.645+05:00' | + | '1984-10-11T12:00+01:00' | '1984-10-11T12:00+01:00' | '1984-10-11T16:00+05:00' | '1984-10-28T12:00:42+01:00' | '1984-10-28T16:00:42+05:00' | And no side effects diff --git a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/TemporalAcceptanceTest.scala b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/TemporalAcceptanceTest.scala index 8db417b4624eb..94d80edef153b 100644 --- a/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/TemporalAcceptanceTest.scala +++ b/enterprise/cypher/acceptance-spec-suite/src/test/scala/org/neo4j/internal/cypher/acceptance/TemporalAcceptanceTest.scala @@ -84,7 +84,8 @@ class TemporalAcceptanceTest extends ExecutionEngineFunSuite with QueryStatistic val queries = Seq("{year:1984, month: 2, week:11}", "{year:1984, month: 2, dayOfWeek:6}", "{year:1984, month: 2, quarter:11}", "{year:1984, month: 2, dayOfQuarter:11}", "{year:1984, week: 2, day:11}", "{year:1984, week: 2, quarter:11}", "{year:1984, week: 2, dayOfQuarter:11}", - "{year:1984, quarter: 2, day:11}", "{year:1984, quarter: 2, dayOfWeek:6}") + "{year:1984, quarter: 2, day:11}", "{year:1984, quarter: 2, dayOfWeek:6}", "{datetime: datetime(), date: date()}", + "{datetime: datetime(), time: time()}") shouldNotConstructWithArg("localdatetime", queries) } @@ -107,7 +108,8 @@ class TemporalAcceptanceTest extends ExecutionEngineFunSuite with QueryStatistic val queries = Seq("{year:1984, month: 2, week:11}", "{year:1984, month: 2, dayOfWeek:6}", "{year:1984, month: 2, quarter:11}", "{year:1984, month: 2, dayOfQuarter:11}", "{year:1984, week: 2, day:11}", "{year:1984, week: 2, quarter:11}", "{year:1984, week: 2, dayOfQuarter:11}", - "{year:1984, quarter: 2, day:11}", "{year:1984, quarter: 2, dayOfWeek:6}") + "{year:1984, quarter: 2, day:11}", "{year:1984, quarter: 2, dayOfWeek:6}", "{datetime: datetime(), date: date()}", + "{datetime: datetime(), time: time()}") shouldNotConstructWithArg("datetime", queries) } @@ -144,32 +146,32 @@ class TemporalAcceptanceTest extends ExecutionEngineFunSuite with QueryStatistic } ignore("should not select time into date") { - shouldNotSelectWithArg[IllegalStateException]("time({hour: 12, minute: 30, second: 40, timezone:'+01:00'})", + shouldNotSelectWithArg[IllegalArgumentException]("time({hour: 12, minute: 30, second: 40, timezone:'+01:00'})", Seq("date"), Seq("{time:x}", "{hour: x.hour}", "{minute: x.minute}", "{second: x.second}", "{timezone: x.timezone}")) } ignore("should not select date into time") { - shouldNotSelectWithArg[IllegalStateException]("date({year:1984, month: 2, day:11})", + shouldNotSelectWithArg[IllegalArgumentException]("date({year:1984, month: 2, day:11})", Seq("time"), Seq("{date:x}", "{year: x.year}", "{month: x.month}", "{day: x.day}")) } ignore("should not select date into local time") { - shouldNotSelectWithArg[IllegalStateException]("date({year:1984, month: 2, day:11})", + shouldNotSelectWithArg[IllegalArgumentException]("date({year:1984, month: 2, day:11})", Seq("localtime"), Seq("{date:x}", "{year: x.year}", "{month: x.month}", "{day: x.day}")) } test("should not select datetime into date") { - shouldNotSelectWithArg[IllegalStateException]("datetime({year:1984, month: 2, day:11, hour: 12, minute: 30, second: 40, timezone:'+01:00'})", + shouldNotSelectWithArg[IllegalArgumentException]("datetime({year:1984, month: 2, day:11, hour: 12, minute: 30, second: 40, timezone:'+01:00'})", Seq("date"), Seq("{datetime:x}")) } test("should not select datetime into time") { - shouldNotSelectWithArg[IllegalStateException]("datetime({year:1984, month: 2, day:11, hour: 12, minute: 30, second: 40, timezone:'+01:00'})", + shouldNotSelectWithArg[IllegalArgumentException]("datetime({year:1984, month: 2, day:11, hour: 12, minute: 30, second: 40, timezone:'+01:00'})", Seq("time"), Seq("{datetime:x}")) } test("should not select datetime into local time") { - shouldNotSelectWithArg[IllegalStateException]("datetime({year:1984, month: 2, day:11, hour: 12, minute: 30, second: 40, timezone:'+01:00'})", + shouldNotSelectWithArg[IllegalArgumentException]("datetime({year:1984, month: 2, day:11, hour: 12, minute: 30, second: 40, timezone:'+01:00'})", Seq("localtime"), Seq("{datetime:x}")) }