[Feature][Spark] Support multiple tables read and write#7283
Conversation
5976900 to
73e3bb1
Compare
|
cc @CheneyYin |
| this.jobName = config.getString("job.name"); | ||
| } | ||
| sparkConf = createSparkConf(); | ||
| sparkConf.set("spark.sql.unsafe.enabled", "false"); |
There was a problem hiding this comment.
I'll remove it. Thank you
| public InternalRow convert(SeaTunnelRow seaTunnelRow) throws IOException { | ||
| validate(seaTunnelRow); | ||
| return (InternalRow) convert(seaTunnelRow, dataType); | ||
| return parcel(seaTunnelRow, (SeaTunnelRowType) dataType); | ||
| } |
There was a problem hiding this comment.
It might be more reliable to add unit tests for it. It would be best if it covers all data types.
There was a problem hiding this comment.
I will refactor and consolidate this part of the logic and provide test cases.
| public SeaTunnelRow reconvert(InternalRow engineRow) throws IOException { | ||
| return (SeaTunnelRow) reconvert(engineRow, dataType); | ||
| return unpack(engineRow, (SeaTunnelRowType) dataType); | ||
| } |
| return newRow; | ||
| } | ||
|
|
||
| public GenericRowWithSchema parcel(SeaTunnelRow seaTunnelRow) { |
| return (SeaTunnelRow) reconvert(engineRow, dataType); | ||
| } | ||
|
|
||
| public SeaTunnelRow unpack(GenericRowWithSchema engineRow) throws IOException { |
| List<String> fieldNames = new ArrayList<>(); | ||
| List<SeaTunnelDataType<?>> fieldTypes = new ArrayList<>(); | ||
| List<ColumnWithIndex> columnWithIndexes = new ArrayList<>(); | ||
| fieldTypes.sort(Comparator.comparingInt(o -> o.getSqlType().ordinal())); |
There was a problem hiding this comment.
fieldTypes is empty. It's meaningless to sort it.
There was a problem hiding this comment.
It's not being used. I'll remove it. Thank you
|
|
||
| public class SchemaUtil { | ||
|
|
||
| public static ColumnWithIndex[] mergeSchema(List<CatalogTable> catalogTables) { |
There was a problem hiding this comment.
It would be better to add unit test cases.
|
waiting for this pr merge |
hailin0
left a comment
There was a problem hiding this comment.
Please add a screenshot of the log for multi-table mapping
| // if (catalogTables.size() != 1) { | ||
| // throw new SeaTunnelException( | ||
| // String.format("Unsupported table number: %d on flink", | ||
| // catalogTables.size())); | ||
| // } |
There was a problem hiding this comment.
This is specifically for multi-table exceptions and can be removed when both spark and flink are implemented
There was a problem hiding this comment.
flink is currently not supported
There was a problem hiding this comment.
It affects not only flink but also spark
There was a problem hiding this comment.
So flink will not throw exception now?
There was a problem hiding this comment.
yes, I think flink is about to implement multiple tables as well
There was a problem hiding this comment.
Let's clean it up when flink implements multiple tables
| } | ||
| this.sparkSession = builder.getOrCreate(); | ||
| createStreamingContext(); | ||
|
|
| TableTransformFactoryContext context = | ||
| new TableTransformFactoryContext( | ||
| Collections.singletonList(dataset.getCatalogTable()), | ||
| Collections.singletonList(dataset.getCatalogTables().get(0)), |
There was a problem hiding this comment.
Maybe you can use dataset.getCatalogTables() instead of Collections.singletonList(dataset.getCatalogTables().get(0)) ?. Like this:
TableTransformFactoryContext context =
new TableTransformFactoryContext(
dataset.getCatalogTables(),
ReadonlyConfig.fromConfig(pluginConfig),
classLoader);There was a problem hiding this comment.
done, excellent advice
| Dataset<Row> stream = tableInfo.getDataset(); | ||
| SeaTunnelDataType<?> inputDataType = tableInfo.getCatalogTable().getSeaTunnelRowType(); | ||
| SeaTunnelDataType<?> inputDataType = | ||
| tableInfo.getCatalogTables().get(0).getSeaTunnelRowType(); |
There was a problem hiding this comment.
Does Covenant transform only deal with the first one?
There was a problem hiding this comment.
This is because 'transform' now supports only single tables
| mockServerClient.retrieveRecordedRequests( | ||
| request().withPath("/example/httpMultiTableContentSink").withMethod("POST"), | ||
| Format.JSON); | ||
| mockServerClient.clear( |
There was a problem hiding this comment.
Sorry, I forgot to clear the records, which caused the run to fail. This test case will run multiple times. Please help add it
There was a problem hiding this comment.
Thank you very much @jackyyyyyssss ,Please cc

close #7009
Purpose of this pull request
Does this PR introduce any user-facing change?
How was this patch tested?
Check list
New License Guide
release-note.