Package org.apache.calcite.adapter.druid
Class TimeExtractionFunction
java.lang.Object
org.apache.calcite.adapter.druid.TimeExtractionFunction
- All Implemented Interfaces:
DruidJson,ExtractionFunction
Implementation of Druid time format extraction function.
These functions return the dimension value formatted according to the given format string, time zone, and locale.
For __time dimension values, this formats the time value bucketed by the aggregation granularity.
-
Constructor Summary
ConstructorsConstructorDescriptionTimeExtractionFunction(String format, Granularity granularity, String timeZone, String local) -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeExtractionFunctioncreateDefault(String timeZone) Creates the default time format extraction function.static TimeExtractionFunctioncreateExtractFromGranularity(Granularity granularity, String timeZone) Creates the time format extraction function for the given granularity.static TimeExtractionFunctioncreateFloorFromGranularity(Granularity granularity, String timeZone) Creates time format floor time extraction function using a given granularity.static booleanisValidTimeExtract(RexNode rexNode) Returns whether the RexCall contains a valid extract unit that we can serialize to Druid.static booleanisValidTimeFloor(RexNode rexNode) Returns whether the RexCall contains a valid FLOOR unit that we can serialize to Druid.static @Nullable TimeExtractionFunctiontranslateCastToTimeExtract(RexNode rexNode, TimeZone timeZone) Translates a CAST expression to a Druid Time extraction function, or null when can not translate the cast.voidwrite(com.fasterxml.jackson.core.JsonGenerator generator)
-
Constructor Details
-
TimeExtractionFunction
public TimeExtractionFunction(String format, Granularity granularity, String timeZone, String local)
-
-
Method Details
-
write
- Specified by:
writein interfaceDruidJson- Throws:
IOException
-
getFormat
-
getGranularity
-
createDefault
Creates the default time format extraction function.- Returns:
- the time extraction function
-
createExtractFromGranularity
public static TimeExtractionFunction createExtractFromGranularity(Granularity granularity, String timeZone) Creates the time format extraction function for the given granularity.- Parameters:
granularity- granularity to apply to the column- Returns:
- the time extraction function corresponding to the granularity input unit
VALID_TIME_EXTRACTfor supported granularity
-
createFloorFromGranularity
public static TimeExtractionFunction createFloorFromGranularity(Granularity granularity, String timeZone) Creates time format floor time extraction function using a given granularity.- Parameters:
granularity- granularity to apply to the column- Returns:
- the time extraction function or null if granularity is not supported
-
isValidTimeExtract
Returns whether the RexCall contains a valid extract unit that we can serialize to Druid.- Parameters:
rexNode- Extract expression- Returns:
- true if the extract unit is valid
-
isValidTimeFloor
Returns whether the RexCall contains a valid FLOOR unit that we can serialize to Druid.- Parameters:
rexNode- Extract expression- Returns:
- true if the extract unit is valid
-
translateCastToTimeExtract
public static @Nullable TimeExtractionFunction translateCastToTimeExtract(RexNode rexNode, TimeZone timeZone) Translates a CAST expression to a Druid Time extraction function, or null when can not translate the cast.- Parameters:
rexNode- CAST RexNodetimeZone- Timezone
-