Skip to content

Conversation

@karuppayya
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the spark label Jun 25, 2021
@karuppayya
Copy link
Contributor Author

Copy link
Contributor

@flyrain flyrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Out of curiosity, in which scenario, method importSparkTable will hit unmatched schema? In the other words, why do we need to check schema? Can we add a test case for that?

try {
CatalogTable sourceCatalogTable = catalog.getTableMetadata(sourceTableIdent);
Preconditions.checkArgument(validateSchema(sourceCatalogTable.schema(), targetTable.schema()),
"The schemas of source table and target table dont match");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont -> don't

}
}

static boolean validateSchema(StructType srcSchema, Schema tgtSchema) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it more suitable to put into SparkSchemaUtil?


import static org.apache.iceberg.types.Types.NestedField.optional;

public class TestSparkTableUtil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some test cases are more suitable for the method SparkSchemaUtil.convert since the method validateSchema didn't do a lot except invoking SparkSchemaUtil.convert() and StructType.equals().

}

static boolean validateSchema(StructType srcSchema, Schema tgtSchema) {
StructType convertSchem = SparkSchemaUtil.convert(tgtSchema);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: convertSchema - missing last a in variable name.

@karuppayya
Copy link
Contributor Author

This PR requires more changes, closing it for now.

@karuppayya karuppayya closed this Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants