void addToContextGroupBy(List<TblColRef> colRefs) { for (TblColRef col : colRefs) { if (!col.isInnerColumn() && this.context.belongToContextTables(col)) this.context.groupByColumns.add(col); } }
public String getTableWithSchema() { if (isInnerColumn() && parserDescription != null) return parserDescription; if (column.getTable() == null) { return "NULL"; } else { return column.getTable().getIdentity().toUpperCase(Locale.ROOT); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; TblColRef other = (TblColRef) obj; if (!StringUtils.equals(column.getTable().getIdentity(), other.column.getTable().getIdentity())) return false; if (!StringUtils.equals(column.getName(), other.column.getName())) return false; if ((table == null ? other.table == null : table.equals(other.table)) == false) return false; if (this.isInnerColumn() != other.isInnerColumn()) return false; return true; }
void translateFilter(OLAPContext context) { if (this.condition == null) { return; } TupleFilterVisitor visitor = new TupleFilterVisitor(this.columnRowType); TupleFilter filter = this.condition.accept(visitor); // optimize the filter, the optimization has to be segment-irrelevant filter = new FilterOptimizeTransformer().transform(filter); Set<TblColRef> filterColumns = Sets.newHashSet(); TupleFilter.collectColumns(filter, filterColumns); for (TblColRef tblColRef : filterColumns) { if (!tblColRef.isInnerColumn() && context.belongToContextTables(tblColRef)) { context.allColumns.add(tblColRef); context.filterColumns.add(tblColRef); } } context.filter = and(context.filter, filter); }
@Override public String toString() { if (isInnerColumn() && parserDescription != null) return parserDescription; String alias = table == null ? "UNKNOWN_MODEL" : table.getAlias(); String tableName = column.getTable() == null ? "NULL" : column.getTable().getName(); String tableIdentity = column.getTable() == null ? "NULL" : column.getTable().getIdentity(); if (alias.equals(tableName)) { return tableIdentity + "." + column.getName(); } else { return alias + ":" + tableIdentity + "." + column.getName(); } }
void buildRewriteFieldsAndMetricsColumns() { ColumnRowType inputColumnRowType = ((OLAPRel) getInput()).getColumnRowType(); RelDataTypeFactory typeFactory = getCluster().getTypeFactory(); for (int i = 0; i < this.aggregations.size(); i++) { FunctionDesc aggFunc = this.aggregations.get(i); if (aggFunc.isDimensionAsMetric()) { addToContextGroupBy(aggFunc.getParameter().getColRefs()); continue; // skip rewrite, let calcite handle } if (aggFunc.needRewriteField()) { String rewriteFieldName = aggFunc.getRewriteFieldName(); RelDataType rewriteFieldType = OLAPTable.createSqlType(typeFactory, aggFunc.getRewriteFieldType(), true); this.context.rewriteFields.put(rewriteFieldName, rewriteFieldType); TblColRef column = buildRewriteColumn(aggFunc); this.context.metricsColumns.add(column); } AggregateCall aggCall = this.rewriteAggCalls.get(i); if (!aggCall.getArgList().isEmpty()) { for (Integer index : aggCall.getArgList()) { TblColRef column = inputColumnRowType.getColumnByIndex(index); if (!column.isInnerColumn() && this.context.belongToContextTables(column)) { this.context.metricsColumns.add(column); } } } } }
if (externalCol.isInnerColumn()) { return ConstantTupleFilter.TRUE;
void addToContextGroupBy(List<TblColRef> colRefs) { for (TblColRef col : colRefs) { if (!col.isInnerColumn() && this.context.belongToContextTables(col)) this.context.groupByColumns.add(col); } }
public String getTableWithSchema() { if (isInnerColumn() && parserDescription != null) return parserDescription; if (column.getTable() == null) { return "NULL"; } else { return column.getTable().getIdentity().toUpperCase(Locale.ROOT); } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; TblColRef other = (TblColRef) obj; if (!StringUtils.equals(column.getTable().getIdentity(), other.column.getTable().getIdentity())) return false; if (!StringUtils.equals(column.getName(), other.column.getName())) return false; if ((table == null ? other.table == null : table.equals(other.table)) == false) return false; if (this.isInnerColumn() != other.isInnerColumn()) return false; return true; }
void translateFilter(OLAPContext context) { if (this.condition == null) { return; } TupleFilterVisitor visitor = new TupleFilterVisitor(this.columnRowType); TupleFilter filter = this.condition.accept(visitor); // optimize the filter, the optimization has to be segment-irrelevant filter = new FilterOptimizeTransformer().transform(filter); Set<TblColRef> filterColumns = Sets.newHashSet(); TupleFilter.collectColumns(filter, filterColumns); for (TblColRef tblColRef : filterColumns) { if (!tblColRef.isInnerColumn() && context.belongToContextTables(tblColRef)) { context.allColumns.add(tblColRef); context.filterColumns.add(tblColRef); } } context.filter = and(context.filter, filter); }
void buildRewriteFieldsAndMetricsColumns() { ColumnRowType inputColumnRowType = ((OLAPRel) getInput()).getColumnRowType(); RelDataTypeFactory typeFactory = getCluster().getTypeFactory(); for (int i = 0; i < this.aggregations.size(); i++) { FunctionDesc aggFunc = this.aggregations.get(i); if (aggFunc.isDimensionAsMetric()) { addToContextGroupBy(aggFunc.getParameter().getColRefs()); continue; // skip rewrite, let calcite handle } if (aggFunc.needRewriteField()) { String rewriteFieldName = aggFunc.getRewriteFieldName(); RelDataType rewriteFieldType = OLAPTable.createSqlType(typeFactory, aggFunc.getRewriteFieldType(), true); this.context.rewriteFields.put(rewriteFieldName, rewriteFieldType); TblColRef column = buildRewriteColumn(aggFunc); this.context.metricsColumns.add(column); } AggregateCall aggCall = this.rewriteAggCalls.get(i); if (!aggCall.getArgList().isEmpty()) { for (Integer index : aggCall.getArgList()) { TblColRef column = inputColumnRowType.getColumnByIndex(index); if (!column.isInnerColumn() && this.context.belongToContextTables(column)) { this.context.metricsColumns.add(column); } } } } }
@Override public String toString() { if (isInnerColumn() && parserDescription != null) return parserDescription; String alias = table == null ? "UNKNOWN_MODEL" : table.getAlias(); String tableName = column.getTable() == null ? "NULL" : column.getTable().getName(); String tableIdentity = column.getTable() == null ? "NULL" : column.getTable().getIdentity(); if (alias.equals(tableName)) { return tableIdentity + "." + column.getName(); } else { return alias + ":" + tableIdentity + "." + column.getName(); } }
if (externalCol.isInnerColumn()) { return ConstantTupleFilter.TRUE;