@Nullable
  public static Granularity toQueryGranularity(final DruidExpression expression, final ExprMacroTable macroTable)
  {
    final TimestampFloorExprMacro.TimestampFloorExpr expr = asTimestampFloorExpr(expression, macroTable);

    if (expr == null) {
      return null;
    }

    final Expr arg = expr.getArg();
    final Granularity granularity = expr.getGranularity();

    if (ColumnHolder.TIME_COLUMN_NAME.equals(Parser.getIdentifierIfIdentifier(arg))) {
      return granularity;
    } else {
      return null;
    }
  }
@ Nullable public static Granularity toQueryGranularity ( final DruidExpression expression , final ExprMacroTable macroTable ) { final TimestampFloorExprMacro . TimestampFloorExpr expr = asTimestampFloorExpr ( expression , macroTable ) ; if ( expr == null ) { return null ; } final Expr arg = expr . getArg ( ) ; final Granularity granularity = expr . getGranularity ( ) ; if ( ColumnHolder . TIME_COLUMN_NAME . equals ( Parser . getIdentifierIfIdentifier ( arg ) ) ) { return granularity ; } else { return null ; } }
Converts an expression to a Granularity, if possible. This is possible if, and only if, the expression
is a timestamp_floor function on the __time column with literal parameters for period, origin, and timeZone.

@return granularity or null if not possible