@Override public int hashCode() { return (this.getNamespace() + this.getTable() + this.getExtractId()).hashCode(); }
@Override public boolean equals(Object object) { if (!(object instanceof Extract)) { return false; } Extract other = (Extract) object; return super.equals(other) && this.getNamespace().equals(other.getNamespace()) && this.getTable().equals(other.getTable()) && this.getExtractId().equals(other.getExtractId()); }
/** * Get the writer output file path corresponding to this {@link Extract}. * * @return writer output file path corresponding to this {@link Extract} * @deprecated As {@code this.getIsFull} is deprecated. */ @Deprecated public String getOutputFilePath() { return this.getNamespace().replaceAll("\\.", "/") + "/" + this.getTable() + "/" + this.getExtractId() + "_" + (this.getIsFull() ? "full" : "append"); }
if (previousExtract.getNamespace().equals(namespace) && previousExtract.getTable().equals(table)) { this.previousTableState.addAll(pre);
@Test public void schemaWithRecordOfEnum() throws Exception { String testName = "schemaWithRecordOfEnum"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); JsonObject expected = getExpectedSchema(testName).getAsJsonObject(); RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something")); Assert.assertEquals(avroSchemaToJsonElement(converter), expected); }
@Test public void schemaWithRecordOfArray() throws Exception { String testName = "schemaWithRecordOfArray"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); JsonObject expected = getExpectedSchema(testName).getAsJsonObject(); RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something")); Assert.assertEquals(avroSchemaToJsonElement(converter), expected); }
@Test public void schemaWithRecordIsNullable() throws Exception { String testName = "schemaWithRecordIsNullable"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); JsonArray expected = getExpectedSchema(testName).getAsJsonArray(); RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something")); Assert.assertEquals(avroSchemaToJsonElement(converter), expected); }
@Test(expectedExceptions = IllegalStateException.class) public void schemaWithMapValuesAsJsonArray() throws Exception { String testName = "schemaWithMapValuesAsJsonArray"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something")); }
@Test public void schemaWithRecordOfMap() throws Exception { String testName = "schemaWithRecordOfMap"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); JsonObject expected = getExpectedSchema(testName).getAsJsonObject(); RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something")); Assert.assertEquals(avroSchemaToJsonElement(converter), expected); }
@Test public void schemaWithRecordOfRecord() throws Exception { String testName = "schemaWithRecordOfRecord"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); JsonObject expected = getExpectedSchema(testName).getAsJsonObject(); RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something")); Assert.assertEquals(avroSchemaToJsonElement(converter), expected); }
@Test public void schemaWithRecord() throws DataConversionException, SchemaConversionException, UnsupportedDateTypeException { String testName = "schemaWithRecord"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); JsonObject expected = getExpectedSchema(testName).getAsJsonObject(); JsonSchema jsonSchema = new JsonSchema(schema); jsonSchema.setColumnName("dummy1"); RecordConverter converter = new RecordConverter(jsonSchema, state, buildNamespace(state.getExtract().getNamespace(), "something")); Assert.assertEquals(avroSchemaToJsonElement(converter), expected); }
@Test(expectedExceptions = UnsupportedOperationException.class) public void schemaWithMapValuesAsJsonNull() throws Exception { String testName = "schemaWithMapValuesAsJsonNull"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something")); }
@Test public void schemaWithRecordOfRecordCheckNamespace() throws Exception { String testName = "schemaWithRecordOfRecordCheckNamespace"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); JsonObject expected = getExpectedSchema(testName).getAsJsonObject(); RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "person")); Assert.assertEquals(avroSchemaToJsonElement(converter), expected); Assert.assertEquals(converter.schema().getField("someperson").schema().getNamespace(), "namespace.person.myrecord"); Assert.assertEquals(converter.schema().getNamespace(), "namespace.person"); }
@Test public void schemaWithRecordOfEnumCheckNamespace() throws Exception { String testName = "schemaWithRecordOfEnumCheckNamespace"; JsonObject schema = getSchemaData(testName).getAsJsonObject(); JsonObject expected = getExpectedSchema(testName).getAsJsonObject(); RecordConverter converter = new RecordConverter(new JsonSchema(schema), state, buildNamespace(state.getExtract().getNamespace(), "something")); Assert.assertEquals(avroSchemaToJsonElement(converter), expected); Assert.assertEquals(converter.schema().getField("someperson").schema().getNamespace(), "namespace.something.myrecord"); Assert.assertEquals(converter.schema().getNamespace(), "namespace.something"); }
@Override public Schema convertSchema(JsonArray schema, WorkUnitState workUnit) throws SchemaConversionException { try { JsonSchema jsonSchema = new JsonSchema(schema); jsonSchema.setColumnName(workUnit.getExtract().getTable()); recordConverter = new RecordConverter(jsonSchema, workUnit, workUnit.getExtract().getNamespace()); } catch (UnsupportedDateTypeException e) { throw new SchemaConversionException(e); } Schema recordSchema = recordConverter.schema(); if (workUnit .getPropAsBoolean(CONVERTER_AVRO_NULLIFY_FIELDS_ENABLED, DEFAULT_CONVERTER_AVRO_NULLIFY_FIELDS_ENABLED)) { return this.generateSchemaWithNullifiedField(workUnit, recordSchema); } return recordSchema; }
table.setNamespace(extract.getNamespace()); table.setName(extract.getTable()); if (extract.hasType()) {
@Override public boolean equals(Object object) { if (!(object instanceof Extract)) { return false; } Extract other = (Extract) object; return super.equals(other) && this.getNamespace().equals(other.getNamespace()) && this.getTable().equals(other.getTable()) && this.getExtractId().equals(other.getExtractId()); }
@Override public int hashCode() { return (this.getNamespace() + this.getTable() + this.getExtractId()).hashCode(); }
/** * Get the writer output file path corresponding to this {@link Extract}. * * @return writer output file path corresponding to this {@link Extract} * @deprecated As {@code this.getIsFull} is deprecated. */ @Deprecated public String getOutputFilePath() { return this.getNamespace().replaceAll("\\.", "/") + "/" + this.getTable() + "/" + this.getExtractId() + "_" + (this.getIsFull() ? "full" : "append"); }
@Override public Schema convertSchema(JsonArray schema, WorkUnitState workUnit) throws SchemaConversionException { try { JsonSchema jsonSchema = new JsonSchema(schema); jsonSchema.setColumnName(workUnit.getExtract().getTable()); recordConverter = new RecordConverter(jsonSchema, workUnit, workUnit.getExtract().getNamespace()); } catch (UnsupportedDateTypeException e) { throw new SchemaConversionException(e); } Schema recordSchema = recordConverter.schema(); if (workUnit .getPropAsBoolean(CONVERTER_AVRO_NULLIFY_FIELDS_ENABLED, DEFAULT_CONVERTER_AVRO_NULLIFY_FIELDS_ENABLED)) { return this.generateSchemaWithNullifiedField(workUnit, recordSchema); } return recordSchema; }