public static final Create sample1() { Create create = new Create(); create.setTable(new GroupSymbol("temp_table"));//$NON-NLS-1$ List elements = new ArrayList(); elements.add(new ElementSymbol("a")); //$NON-NLS-1$ elements.add(new ElementSymbol("b")); //$NON-NLS-1$ create.setElementSymbolsAsColumns(elements); return create; }
public static final Create sample2() { Create create = new Create(); create.setTable(new GroupSymbol("temp_table2"));//$NON-NLS-1$ List elements = new ArrayList(); elements.add(new ElementSymbol("a")); //$NON-NLS-1$ elements.add(new ElementSymbol("b")); //$NON-NLS-1$ create.setElementSymbolsAsColumns(elements); return create; }
public static Create getCreateCommand(GroupSymbol group, boolean matview, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Create create = new Create(); create.setTable(group); List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata); create.setElementSymbolsAsColumns(allColumns); if (!matview) { for (int i = 0; i < allColumns.size(); i++) { ElementSymbol es = allColumns.get(i); if (!metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { create.getColumns().get(i).setNullType(NullType.No_Nulls); if (es.getType() == DataTypeManager.DefaultDataClasses.INTEGER && metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT)) { create.getColumns().get(i).setAutoIncremented(true); //serial } } } } Object pk = metadata.getPrimaryKey(group.getMetadataID()); if (pk != null) { List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk); create.getPrimaryKey().addAll(pkColumns); } return create; }
public static Create getCreateCommand(GroupSymbol group, boolean matview, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Create create = new Create(); create.setTable(group); List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata); create.setElementSymbolsAsColumns(allColumns); if (!matview) { for (int i = 0; i < allColumns.size(); i++) { ElementSymbol es = allColumns.get(i); if (!metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { create.getColumns().get(i).setNullType(NullType.No_Nulls); if (es.getType() == DataTypeManager.DefaultDataClasses.INTEGER && metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT)) { create.getColumns().get(i).setAutoIncremented(true); //serial } } } } Object pk = metadata.getPrimaryKey(group.getMetadataID()); if (pk != null) { List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk); create.getPrimaryKey().addAll(pkColumns); } return create; }
public static Create getCreateCommand(GroupSymbol group, boolean matview, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException { Create create = new Create(); create.setTable(group); List<ElementSymbol> allColumns = ResolverUtil.resolveElementsInGroup(group, metadata); create.setElementSymbolsAsColumns(allColumns); if (!matview) { for (int i = 0; i < allColumns.size(); i++) { ElementSymbol es = allColumns.get(i); if (!metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.NULL)) { create.getColumns().get(i).setNullType(NullType.No_Nulls); if (es.getType() == DataTypeManager.DefaultDataClasses.INTEGER && metadata.elementSupports(es.getMetadataID(), SupportConstants.Element.AUTO_INCREMENT)) { create.getColumns().get(i).setAutoIncremented(true); //serial } } } } Object pk = metadata.getPrimaryKey(group.getMetadataID()); if (pk != null) { List<ElementSymbol> pkColumns = resolveIndex(metadata, allColumns, pk); create.getPrimaryKey().addAll(pkColumns); } return create; }
/** * @see org.teiid.query.sql.lang.Command#clone() * @since 5.5 */ public Object clone() { Create copy = new Create(); GroupSymbol copyTable = table.clone(); copy.setTable(copyTable); copy.columns = new ArrayList<Column>(columns.size()); for (Column column : columns) { Column copyColumn = new Column(); copyColumn.setName(column.getName()); copyColumn.setRuntimeType(column.getRuntimeType()); copyColumn.setAutoIncremented(column.isAutoIncremented()); copyColumn.setNullType(column.getNullType()); copy.columns.add(copyColumn); } copy.primaryKey = LanguageObject.Util.deepClone(primaryKey, ElementSymbol.class); copyMetadataState(copy); copy.setTableMetadata(this.tableMetadata); copy.on = this.on; copy.commitAction = this.commitAction; return copy; }
/** * @see org.teiid.query.sql.lang.Command#clone() * @since 5.5 */ public Object clone() { Create copy = new Create(); GroupSymbol copyTable = table.clone(); copy.setTable(copyTable); copy.columns = new ArrayList<Column>(columns.size()); for (Column column : columns) { Column copyColumn = new Column(); copyColumn.setName(column.getName()); copyColumn.setRuntimeType(column.getRuntimeType()); copyColumn.setAutoIncremented(column.isAutoIncremented()); copyColumn.setNullType(column.getNullType()); copy.columns.add(copyColumn); } copy.primaryKey = LanguageObject.Util.deepClone(primaryKey, ElementSymbol.class); copyMetadataState(copy); copy.setTableMetadata(this.tableMetadata); copy.on = this.on; copy.commitAction = this.commitAction; return copy; }
/** * @see org.teiid.query.sql.lang.Command#clone() * @since 5.5 */ public Object clone() { Create copy = new Create(); GroupSymbol copyTable = table.clone(); copy.setTable(copyTable); copy.columns = new ArrayList<Column>(columns.size()); for (Column column : columns) { Column copyColumn = new Column(); copyColumn.setName(column.getName()); copyColumn.setRuntimeType(column.getRuntimeType()); copyColumn.setAutoIncremented(column.isAutoIncremented()); copyColumn.setNullType(column.getNullType()); copy.columns.add(copyColumn); } copy.primaryKey = LanguageObject.Util.deepClone(primaryKey, ElementSymbol.class); copyMetadataState(copy); copy.setTableMetadata(this.tableMetadata); copy.on = this.on; copy.commitAction = this.commitAction; return copy; }
@Test public void testCreateTempTableWithPrimaryKey() { Create create = new Create(); create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$ List<ElementSymbol> columns = new ArrayList<ElementSymbol>(); ElementSymbol column = new ElementSymbol("c1");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.BOOLEAN); columns.add(column); column = new ElementSymbol("c2");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.BYTE); columns.add(column); create.setElementSymbolsAsColumns(columns); create.getPrimaryKey().add(column); helpTest("Create local TEMPORARY table tempTable(c1 boolean, c2 byte, primary key (c2))", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 boolean, c2 byte, PRIMARY KEY(c2))", create); //$NON-NLS-1$ //$NON-NLS-2$ }
@Test public void testCreateTempTable2() { Create create = new Create(); create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$ List<ElementSymbol> columns = new ArrayList<ElementSymbol>(); ElementSymbol column = new ElementSymbol("c1");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.BOOLEAN); columns.add(column); column = new ElementSymbol("c2");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.BYTE); columns.add(column); create.setElementSymbolsAsColumns(columns); create.getColumns().get(0).setNullType(NullType.No_Nulls); helpTest("Create local TEMPORARY table tempTable(c1 boolean not null, c2 byte)", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 boolean NOT NULL, c2 byte)", create); //$NON-NLS-1$ //$NON-NLS-2$ }
@Test public void testCreateTempTable1() { Create create = new Create(); create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$ List<ElementSymbol> columns = new ArrayList<ElementSymbol>(); ElementSymbol column = new ElementSymbol("c1");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.BOOLEAN); columns.add(column); column = new ElementSymbol("c2");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.BYTE); columns.add(column); create.setElementSymbolsAsColumns(columns); create.setCommitAction(CommitAction.PRESERVE_ROWS); helpTest("Create local TEMPORARY table tempTable (c1 boolean, c2 byte) on commit preserve rows", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 boolean, c2 byte) ON COMMIT PRESERVE ROWS", create); //$NON-NLS-1$ //$NON-NLS-2$ }
@Test public void testTypeAliases() { Create create = new Create(); create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$ List<ElementSymbol> columns = new ArrayList<ElementSymbol>(); ElementSymbol column = new ElementSymbol("c1");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.STRING); columns.add(column); column = new ElementSymbol("c2");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.BYTE); columns.add(column); column = new ElementSymbol("c3");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.SHORT); columns.add(column); column = new ElementSymbol("c4");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.FLOAT); columns.add(column); column = new ElementSymbol("c5");//$NON-NLS-1$ column.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL); columns.add(column); create.setElementSymbolsAsColumns(columns); helpTest("Create local TEMPORARY table tempTable (c1 varchar, c2 tinyint, c3 smallint, c4 real, c5 decimal)", "CREATE LOCAL TEMPORARY TABLE tempTable (c1 varchar, c2 tinyint, c3 smallint, c4 real, c5 decimal)", create); //$NON-NLS-1$ }
if (withProcessor != null) { LogManager.logDetail(LogConstants.CTX_DQP, "Creating temporary table for with clause", tempTableID); //$NON-NLS-1$ Create create = new Create(); create.setTable(new GroupSymbol(tempTableID)); create.setElementSymbolsAsColumns(withProcessor.columns); Create create = new Create(); create.setTable(new GroupSymbol(tempTableID)); create.setElementSymbolsAsColumns(columns);
if (withProcessor != null) { LogManager.logDetail(LogConstants.CTX_DQP, "Creating temporary table for with clause", tempTableID); //$NON-NLS-1$ Create create = new Create(); create.setTable(new GroupSymbol(tempTableID)); create.setElementSymbolsAsColumns(withProcessor.columns); Create create = new Create(); create.setTable(new GroupSymbol(tempTableID)); create.setElementSymbolsAsColumns(columns);
jj_consume_token(ON); model = id(null); Create create = new Create(); create.setTableMetadata(table); create.setOn(model);
jj_consume_token(ON); model = id(null); Create create = new Create(); create.setTableMetadata(table); create.setOn(model);
final public Command createTempTable(ParseInfo info) throws ParseException { Create create = new Create(); String table = null; String pkId = null;
jj_consume_token(ON); model = id(null); Create create = new Create(); create.setTableMetadata(table); create.setOn(model);
final public Command createTempTable(ParseInfo info) throws ParseException { Create create = new Create(); String table = null; String pkId = null;
@Test public void testForeignTemp() { Create create = new Create(); create.setTable(new GroupSymbol("tempTable")); //$NON-NLS-1$ create.setOn("source"); Table t = new Table(); t.setName("tempTable"); t.setUUID("tid:0"); Column c = new Column(); c.setName("x"); c.setUUID("tid:0"); Datatype string = SystemMetadata.getInstance().getRuntimeTypeMap().get("string"); c.setDatatype(string, true, 0); t.addColumn(c); c = new Column(); c.setName("y"); c.setUUID("tid:0"); Datatype decimal = SystemMetadata.getInstance().getRuntimeTypeMap().get("decimal"); c.setDatatype(decimal, true, 0); t.addColumn(c); t.setCardinality(10000); create.setTableMetadata(t); helpTest("create foreign temporary table tempTable (x string, y decimal) options (cardinality 10000) on source", "CREATE FOREIGN TEMPORARY TABLE tempTable (\n x string,\n y bigdecimal\n) OPTIONS (CARDINALITY 10000) ON 'source'", create); //$NON-NLS-1$ //$NON-NLS-2$ }