### Question:
DateRangeRules { static ImmutableSortedSet<TimeUnitRange> extractTimeUnits( RexNode e ) { try ( ExtractFinder finder = ExtractFinder.THREAD_INSTANCES.get() ) { assert finder.timeUnits.isEmpty() && finder.opKinds.isEmpty() : "previous user did not clean up"; e.accept( finder ); return ImmutableSortedSet.copyOf( finder.timeUnits ); } } private  DateRangeRules(); @VisibleForTesting static RexNode replaceTimeUnits( RexBuilder rexBuilder, RexNode e, String timeZone ); static final RelOptRule FILTER_INSTANCE; }### Answer:
@Test public void testExtractYearFromDateColumn() { final Fixture2 f = new Fixture2(); final RexNode e = f.eq( f.literal( 2014 ), f.exYearD ); assertThat( DateRangeRules.extractTimeUnits( e ), is( set( TimeUnitRange.YEAR ) ) ); assertThat( DateRangeRules.extractTimeUnits( f.dec ), is( set() ) ); assertThat( DateRangeRules.extractTimeUnits( f.literal( 1 ) ), is( set() ) ); checkDateRange( f, e, is( "AND(>=($8, 2014-01-01), <($8, 2015-01-01))" ) ); checkDateRange( f, f.eq( f.exYearD, f.literal( 2014 ) ), is( "AND(>=($8, 2014-01-01), <($8, 2015-01-01))" ) ); checkDateRange( f, f.ge( f.exYearD, f.literal( 2014 ) ), is( ">=($8, 2014-01-01)" ) ); checkDateRange( f, f.gt( f.exYearD, f.literal( 2014 ) ), is( ">=($8, 2015-01-01)" ) ); checkDateRange( f, f.lt( f.exYearD, f.literal( 2014 ) ), is( "<($8, 2014-01-01)" ) ); checkDateRange( f, f.le( f.exYearD, f.literal( 2014 ) ), is( "<($8, 2015-01-01)" ) ); checkDateRange( f, f.ne( f.exYearD, f.literal( 2014 ) ), is( "<>(EXTRACT(FLAG(YEAR), $8), 2014)" ) ); }