@SuppressWarnings("deprecation") public boolean isGeneratedAlways(RelOptTable table, int iColumn) { switch (generationStrategy(table, iColumn)) { case VIRTUAL: case STORED: return true; default: return false; } }
@Override public RexNode newAttributeInitializer(RelDataType type, SqlFunction constructor, int iAttribute, List<RexNode> constructorArgs, InitializerContext context) { THREAD_CALL_COUNT.get().incrementAndGet(); return super.newAttributeInitializer(type, constructor, iAttribute, constructorArgs, context); } }
@Override public RexNode newColumnDefaultValue(RelOptTable table, int iColumn, InitializerContext context) { THREAD_CALL_COUNT.get().incrementAndGet(); final RelDataTypeField field = table.getRowType().getFieldList().get(iColumn); if (defaultColumns.contains(field.getName())) { final RexBuilder rexBuilder = context.getRexBuilder(); return rexBuilder.makeExactLiteral(BigDecimal.ONE); } return super.newColumnDefaultValue(table, iColumn, context); }
private InitializerExpressionFactory getInitializerFactory( SqlValidatorTable validatorTable) { // We might unwrap a null instead of a InitializerExpressionFactory. final Table table = unwrap(validatorTable, Table.class); if (table != null) { InitializerExpressionFactory f = unwrap(table, InitializerExpressionFactory.class); if (f != null) { return f; } } return new NullInitializerExpressionFactory(); }
@Override public RexNode newColumnDefaultValue(RelOptTable table, int iColumn, InitializerContext context) { THREAD_CALL_COUNT.get().incrementAndGet(); final RelDataTypeField field = table.getRowType().getFieldList().get(iColumn); if (defaultColumns.contains(field.getName())) { final RexBuilder rexBuilder = context.getRexBuilder(); return rexBuilder.makeExactLiteral(BigDecimal.ONE); } return super.newColumnDefaultValue(table, iColumn, context); }
private InitializerExpressionFactory getInitializerFactory( SqlValidatorTable validatorTable) { // We might unwrap a null instead of a InitializerExpressionFactory. final Table table = unwrap(validatorTable, Table.class); if (table != null) { InitializerExpressionFactory f = unwrap(table, InitializerExpressionFactory.class); if (f != null) { return f; } } return new NullInitializerExpressionFactory(typeFactory); }
@SuppressWarnings("deprecation") public boolean isGeneratedAlways(RelOptTable table, int iColumn) { switch (generationStrategy(table, iColumn)) { case VIRTUAL: case STORED: return true; default: return false; } }
@Override public RexNode newColumnDefaultValue(RelOptTable table, int iColumn, InitializerContext context) { final ModifiableViewTable viewTable = table.unwrap(ModifiableViewTable.class); assert iColumn < viewTable.columnMapping.size(); final RexBuilder rexBuilder = context.getRexBuilder(); final RelDataTypeFactory typeFactory = rexBuilder.getTypeFactory(); final RelDataType viewType = viewTable.getRowType(typeFactory); final RelDataType iType = viewType.getFieldList().get(iColumn).getType(); // Use the view constraint to generate the default value if the column is constrained. final int mappedOrdinal = viewTable.columnMapping.get(iColumn); final RexNode viewConstraint = projectMap.get(mappedOrdinal); if (viewConstraint != null) { return rexBuilder.ensureType(iType, viewConstraint, true); } // Otherwise use the default value of the underlying table. final Table schemaTable = viewTable.getTable(); if (schemaTable instanceof Wrapper) { final InitializerExpressionFactory initializerExpressionFactory = ((Wrapper) schemaTable).unwrap(InitializerExpressionFactory.class); if (initializerExpressionFactory != null) { final RexNode tableConstraint = initializerExpressionFactory.newColumnDefaultValue(table, iColumn, context); return rexBuilder.ensureType(iType, tableConstraint, true); } } // Otherwise Sql type of NULL. return super.newColumnDefaultValue(table, iColumn, context); }
@Override public RexNode newAttributeInitializer(RelDataType type, SqlFunction constructor, int iAttribute, List<RexNode> constructorArgs, InitializerContext context) { THREAD_CALL_COUNT.get().incrementAndGet(); return super.newAttributeInitializer(type, constructor, iAttribute, constructorArgs, context); } }
@Override public ColumnStrategy generationStrategy(RelOptTable table, int iColumn) { switch (iColumn) { case 0: case 1: case 5: return ColumnStrategy.DEFAULT; default: return super.generationStrategy(table, iColumn); } }
@Override public RexNode newColumnDefaultValue(RelOptTable table, int iColumn, InitializerContext context) { final ModifiableViewTable viewTable = table.unwrap(ModifiableViewTable.class); assert iColumn < viewTable.columnMapping.size(); final RexBuilder rexBuilder = context.getRexBuilder(); final RelDataTypeFactory typeFactory = rexBuilder.getTypeFactory(); final RelDataType viewType = viewTable.getRowType(typeFactory); final RelDataType iType = viewType.getFieldList().get(iColumn).getType(); // Use the view constraint to generate the default value if the column is constrained. final int mappedOrdinal = viewTable.columnMapping.get(iColumn); final RexNode viewConstraint = projectMap.get(mappedOrdinal); if (viewConstraint != null) { return rexBuilder.ensureType(iType, viewConstraint, true); } // Otherwise use the default value of the underlying table. final Table schemaTable = viewTable.getTable(); if (schemaTable instanceof Wrapper) { final InitializerExpressionFactory initializerExpressionFactory = ((Wrapper) schemaTable).unwrap(InitializerExpressionFactory.class); if (initializerExpressionFactory != null) { final RexNode tableConstraint = initializerExpressionFactory.newColumnDefaultValue(table, iColumn, context); return rexBuilder.ensureType(iType, tableConstraint, true); } } // Otherwise Sql type of NULL. return super.newColumnDefaultValue(table, iColumn, context); }
@Override public ColumnStrategy generationStrategy(RelOptTable table, int iColumn) { switch (iColumn) { case 0: case 1: case 5: return ColumnStrategy.DEFAULT; default: return super.generationStrategy(table, iColumn); } }
@Override public ColumnStrategy generationStrategy(RelOptTable table, int iColumn) { final RelDataTypeField field = table.getRowType().getFieldList().get(iColumn); if (defaultColumns.contains(field.getName())) { return ColumnStrategy.DEFAULT; } return super.generationStrategy(table, iColumn); }
@Override public ColumnStrategy generationStrategy(RelOptTable table, int iColumn) { final RelDataTypeField field = table.getRowType().getFieldList().get(iColumn); if (defaultColumns.contains(field.getName())) { return ColumnStrategy.DEFAULT; } return super.generationStrategy(table, iColumn); }
@Override public ColumnStrategy generationStrategy(RelOptTable table, int iColumn) { final ModifiableViewTable viewTable = table.unwrap(ModifiableViewTable.class); assert iColumn < viewTable.columnMapping.size(); // Use the view constraint to generate the default value if the column is // constrained. final int mappedOrdinal = viewTable.columnMapping.get(iColumn); final RexNode viewConstraint = projectMap.get(mappedOrdinal); if (viewConstraint != null) { return ColumnStrategy.DEFAULT; } // Otherwise use the default value of the underlying table. final Table schemaTable = viewTable.getTable(); if (schemaTable instanceof Wrapper) { final InitializerExpressionFactory initializerExpressionFactory = ((Wrapper) schemaTable).unwrap(InitializerExpressionFactory.class); if (initializerExpressionFactory != null) { return initializerExpressionFactory.generationStrategy(table, iColumn); } } return super.generationStrategy(table, iColumn); }
@Override public ColumnStrategy generationStrategy(RelOptTable table, int iColumn) { final ModifiableViewTable viewTable = table.unwrap(ModifiableViewTable.class); assert iColumn < viewTable.columnMapping.size(); // Use the view constraint to generate the default value if the column is // constrained. final int mappedOrdinal = viewTable.columnMapping.get(iColumn); final RexNode viewConstraint = projectMap.get(mappedOrdinal); if (viewConstraint != null) { return ColumnStrategy.DEFAULT; } // Otherwise use the default value of the underlying table. final Table schemaTable = viewTable.getTable(); if (schemaTable instanceof Wrapper) { final InitializerExpressionFactory initializerExpressionFactory = ((Wrapper) schemaTable).unwrap(InitializerExpressionFactory.class); if (initializerExpressionFactory != null) { return initializerExpressionFactory.generationStrategy(table, iColumn); } } return super.generationStrategy(table, iColumn); }