forked from apache/seatunnel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bugfix][Connector-v2] fix file sink
isPartitionFieldWriteInFile
oc…
…curred exception when no columns are give for the sink
- Loading branch information
wei.zhao
committed
Sep 16, 2023
1 parent
0ce1712
commit f0b2981
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...c/test/java/org/apache/seatunnel/connectors/seatunnel/file/writer/FileSinkConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.seatunnel.connectors.seatunnel.file.writer; | ||
|
||
import org.apache.seatunnel.shade.com.typesafe.config.Config; | ||
import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory; | ||
|
||
import org.apache.seatunnel.api.table.type.BasicType; | ||
import org.apache.seatunnel.api.table.type.SeaTunnelDataType; | ||
import org.apache.seatunnel.api.table.type.SeaTunnelRowType; | ||
import org.apache.seatunnel.connectors.seatunnel.file.sink.config.FileSinkConfig; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
import java.nio.file.Paths; | ||
|
||
public class FileSinkConfigTest { | ||
|
||
@Test | ||
public void testConfigInit() throws Exception { | ||
URL conf = OrcReadStrategyTest.class.getResource("/test_write_hdfs.conf"); | ||
Assertions.assertNotNull(conf); | ||
String confPath = Paths.get(conf.toURI()).toString(); | ||
Config config = ConfigFactory.parseFile(new File(confPath)); | ||
|
||
SeaTunnelRowType rowType = | ||
new SeaTunnelRowType( | ||
new String[] {"data", "ts"}, | ||
new SeaTunnelDataType[] {BasicType.STRING_TYPE, BasicType.STRING_TYPE}); | ||
Assertions.assertDoesNotThrow(() -> new FileSinkConfig(config, rowType)); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...-connectors-v2/connector-file/connector-file-base/src/test/resources/test_write_hdfs.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
fs.defaultFS = "hdfs://hadoop01:9000" | ||
have_partition = true | ||
partition_by = ["ts"] | ||
partition_dir_expression = "${v0}" | ||
is_partition_field_write_in_file = false | ||
path = "/data/test" | ||
file_format_type = "json" | ||
batch_size=10 | ||
} | ||
|