public MetadataFactory getTempMetadataFactory() { if (this.metadataFactory == null) { this.metadataFactory = new MetadataFactory("temp", 1, "temp", SystemMetadata.getInstance().getRuntimeTypeMap(), null, null); //$NON-NLS-1$ //$NON-NLS-2$ } return this.metadataFactory; }
public static final void validateFunctionMethods(Collection<FunctionMethod> methods, ValidatorReport report, Map<String, Datatype> runtimeTypeMap) { if (runtimeTypeMap == null) { runtimeTypeMap = SystemMetadata.getInstance().getRuntimeTypeMap(); } if(methods != null) { for (FunctionMethod method : methods) { validateFunctionMethod(method, report, runtimeTypeMap); } } }
public MetadataFactory getTempMetadataFactory() { if (this.metadataFactory == null) { this.metadataFactory = new MetadataFactory("temp", 1, "temp", SystemMetadata.getInstance().getRuntimeTypeMap(), null, null); //$NON-NLS-1$ //$NON-NLS-2$ } return this.metadataFactory; }
public static final void validateFunctionMethods(Collection<FunctionMethod> methods, ValidatorReport report, Map<String, Datatype> runtimeTypeMap) { if (runtimeTypeMap == null) { runtimeTypeMap = SystemMetadata.getInstance().getRuntimeTypeMap(); } if(methods != null) { for (FunctionMethod method : methods) { validateFunctionMethod(method, report, runtimeTypeMap); } } }
public static final void validateFunctionMethods(Collection<FunctionMethod> methods, ValidatorReport report, Map<String, Datatype> runtimeTypeMap) { if (runtimeTypeMap == null) { runtimeTypeMap = SystemMetadata.getInstance().getRuntimeTypeMap(); } if(methods != null) { for (FunctionMethod method : methods) { validateFunctionMethod(method, report, runtimeTypeMap); } } }
public MetadataFactory getTempMetadataFactory() { if (this.metadataFactory == null) { this.metadataFactory = new MetadataFactory("temp", 1, "temp", SystemMetadata.getInstance().getRuntimeTypeMap(), null, null); //$NON-NLS-1$ //$NON-NLS-2$ } return this.metadataFactory; }
public MetadataValidator() { this.typeMap = SystemMetadata.getInstance().getRuntimeTypeMap(); this.parser = QueryParser.getQueryParser(); }
public MetadataValidator() { this.typeMap = SystemMetadata.getInstance().getRuntimeTypeMap(); this.parser = QueryParser.getQueryParser(); }
public MetadataValidator() { this.typeMap = SystemMetadata.getInstance().getRuntimeTypeMap(); this.parser = QueryParser.getQueryParser(); }
public static Map<String, Datatype> getDataTypes() { return SystemMetadata.getInstance().getRuntimeTypeMap(); }
public void addUDF(String schema, Collection<FunctionMethod> methods) { if (methods == null || methods.isEmpty()) { return; } this.functions.add(new FunctionTree(schema, new UDFSource(methods))); SystemFunctionManager sfm = SystemMetadata.getInstance().getSystemFunctionManager(); functionLibrary = new FunctionLibrary(sfm.getSystemFunctions(), this.functions.toArray(new FunctionTree[this.functions.size()])); }
public static IndexVDB loadMetadata(String vdbName, URL url) throws IOException, MalformedURLException { VirtualFile root; try { root = PureZipFileSystem.mount(url); } catch (URISyntaxException e) { throw new IOException(e); } IndexVDB result = new IndexVDB(); result.resources = new VDBResources(root, null); IndexMetadataRepository store = new IndexMetadataRepository(); result.store = store.load(SystemMetadata.getInstance().getDataTypes(), result.resources); return result; } }
private void visit(Datatype dt) { append(CREATE).append(SPACE).append(DOMAIN).append(SPACE); append(SQLStringVisitor.escapeSinglePart(dt.getName())).append(SPACE).append(AS).append(SPACE); String runtimeTypeName = dt.getBasetypeName(); append(runtimeTypeName); Datatype base = SystemMetadata.getInstance().getRuntimeTypeMap().get(runtimeTypeName); if (LENGTH_DATATYPES.contains(runtimeTypeName)) { if (dt.getLength() != base.getLength()) { append(LPAREN).append(dt.getLength()).append(RPAREN); } } else if (PRECISION_DATATYPES.contains(runtimeTypeName) && (dt.getPrecision() != base.getPrecision() || dt.getScale() != base.getScale())) { append(LPAREN).append(dt.getPrecision()); if (dt.getScale() != 0) { append(COMMA).append(dt.getScale()); } append(RPAREN); } if (dt.getNullType() == NullType.No_Nulls) { append(SPACE).append(NOT_NULL); } append(SEMICOLON); }
@Test public void testTypeCorrection() throws Exception { MetadataFactory mf = new MetadataFactory(null, 1, "x", SystemMetadata.getInstance().getRuntimeTypeMap(), new Properties(), null); //$NON-NLS-1$ Table t = mf.addTable("y"); //$NON-NLS-1$ mf.addColumn("test", "string", t); mf.addColumn("array", "string[]", t); Datatype unknown = new Datatype(); unknown.setName("unknown"); Column col = mf.addColumn("arg", "string", t); col.setDatatype(unknown, false, 0); MetadataFactory mf1 = UnitTestUtil.helpSerialize(mf); Column column = mf1.getSchema().getTable("y").getColumns().get(0); Datatype dt = column.getDatatype(); assertNotSame(mf.getDataTypes().get(dt.getName()), column.getDatatype()); assertEquals(1, mf1.getSchema().getTable("y").getColumns().get(1).getArrayDimensions()); mf1.correctDatatypes(mf.getDataTypes()); assertSame(mf.getDataTypes().get(dt.getName()), column.getDatatype()); assertEquals(1, mf1.getSchema().getTable("y").getColumns().get(1).getArrayDimensions()); }
@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$ }
@Test public void testGeometryTypes() { Column c = new Column(); c.setDatatype(SystemMetadata.getInstance().getRuntimeTypeMap().get(DefaultDataTypes.GEOMETRY)); c.setProperty(BaseColumn.SPATIAL_TYPE, "MULTIPOLYGON"); //$NON-NLS-1$ assertEquals("GeometryMultiPolygon", ODataTypeManager.odataType(c).name()); c.setProperty(BaseColumn.SPATIAL_TYPE, "LINESTRING"); //$NON-NLS-1$ assertEquals("GeometryLineString", ODataTypeManager.odataType(c).name()); assertEquals("geometry", ODataTypeManager.teiidType(EdmGeometryPoint.getInstance(), false)); }
@Test public void testGeographyTypes() { Column c = new Column(); c.setDatatype(SystemMetadata.getInstance().getRuntimeTypeMap().get(DefaultDataTypes.GEOGRAPHY)); c.setProperty(BaseColumn.SPATIAL_TYPE, "MULTILINESTRING"); //$NON-NLS-1$ assertEquals("GeographyMultiLineString", ODataTypeManager.odataType(c).name()); c.setProperty(BaseColumn.SPATIAL_TYPE, "POLYGON"); //$NON-NLS-1$ assertEquals("GeographyPolygon", ODataTypeManager.odataType(c).name()); assertEquals("geography", ODataTypeManager.teiidType(EdmGeographyPoint.getInstance(), false)); }
private void visit(Datatype dt) { append(CREATE).append(SPACE).append(DOMAIN).append(SPACE); append(SQLStringVisitor.escapeSinglePart(dt.getName())).append(SPACE).append(AS).append(SPACE); String runtimeTypeName = dt.getBasetypeName(); append(runtimeTypeName); Datatype base = SystemMetadata.getInstance().getRuntimeTypeMap().get(runtimeTypeName); if (DataTypeManager.hasLength(runtimeTypeName)) { if (dt.getLength() != base.getLength()) { append(LPAREN).append(dt.getLength()).append(RPAREN); } } else if (PRECISION_DATATYPES.contains(runtimeTypeName) && (dt.getPrecision() != base.getPrecision() || dt.getScale() != base.getScale())) { append(LPAREN).append(dt.getPrecision()); if (dt.getScale() != 0) { append(COMMA).append(dt.getScale()); } append(RPAREN); } if (dt.getNullType() == NullType.No_Nulls) { append(SPACE).append(NOT_NULL); } append(SEMICOLON); }
private ModelMetaData buildSourceTableWithCompositePK() { ModelMetaData model = new ModelMetaData(); model.setName("source"); model.setModelType(Model.Type.PHYSICAL); MetadataFactory target = new MetadataFactory(VDBNAME, VDBVERSION, SystemMetadata.getInstance().getRuntimeTypeMap(), model); Table t = target.addTable("Person"); target.addColumn("id", "integer", t); target.addColumn("name", "string", t); target.addColumn("dob", "date", t); target.addPrimaryKey("PK", Arrays.asList("id", "name"), t); String ddl = DDLStringVisitor.getDDLString(target.getSchema(), null, null); model.addSourceMetadata("ddl", ddl); model.addAttchment(MetadataFactory.class, target); return model; }
private ModelMetaData buildSourceTable() { ModelMetaData model = new ModelMetaData(); model.setName("source"); model.setModelType(Model.Type.PHYSICAL); MetadataFactory target = new MetadataFactory(VDBNAME, VDBVERSION, SystemMetadata.getInstance().getRuntimeTypeMap(), model); Table t = target.addTable("Person"); target.addColumn("id", "integer", t); target.addColumn("name", "string", t); target.addColumn("dob", "date", t); model.addAttchment(MetadataFactory.class, target); String ddl = DDLStringVisitor.getDDLString(target.getSchema(), null, null); model.addSourceMetadata("ddl", ddl); return model; }