-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-30093] Fix outerProtoPrefix to be generated from descriptor
- Loading branch information
1 parent
8fa7fa5
commit d2ccf3f
Showing
16 changed files
with
341 additions
and
34 deletions.
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
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
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
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
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
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
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
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
44 changes: 44 additions & 0 deletions
44
...link-protobuf/src/test/java/org/apache/flink/formats/protobuf/SameOuterClassNameTest.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,44 @@ | ||
/* | ||
* 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.flink.formats.protobuf; | ||
|
||
import org.apache.flink.formats.protobuf.testproto.TestSameOuterClassNameOuterClass; | ||
import org.apache.flink.table.data.RowData; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** Test conversion of proto same outer class name data to flink internal data. */ | ||
public class SameOuterClassNameTest { | ||
|
||
@Test | ||
public void testSimple() throws Exception { | ||
TestSameOuterClassNameOuterClass.TestSameOuterClassName testSameOuterClassName = | ||
TestSameOuterClassNameOuterClass.TestSameOuterClassName.newBuilder() | ||
.setA(1) | ||
.build(); | ||
RowData row = | ||
ProtobufTestHelper.pbBytesToRow( | ||
TestSameOuterClassNameOuterClass.TestSameOuterClassName.class, | ||
testSameOuterClassName.toByteArray()); | ||
|
||
assertEquals(1, row.getInt(0)); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ink-protobuf/src/test/java/org/apache/flink/formats/protobuf/TimestampMultiToRowTest.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,47 @@ | ||
/* | ||
* 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.flink.formats.protobuf; | ||
|
||
import org.apache.flink.formats.protobuf.testproto.TestTimestamp.TimestampTest; | ||
import org.apache.flink.formats.protobuf.testproto.TimestampTestMulti; | ||
import org.apache.flink.table.data.RowData; | ||
|
||
import com.google.protobuf.Timestamp; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** Test conversion of proto timestamp data with multiple_files options to flink internal data. */ | ||
public class TimestampMultiToRowTest { | ||
|
||
@Test | ||
public void testSimple() throws Exception { | ||
TimestampTestMulti timestampTestMulti = | ||
TimestampTestMulti.newBuilder() | ||
.setTs(Timestamp.newBuilder().setSeconds(1672498800).setNanos(123)) | ||
.build(); | ||
RowData row = | ||
ProtobufTestHelper.pbBytesToRow( | ||
TimestampTest.class, timestampTestMulti.toByteArray()); | ||
|
||
RowData rowData = row.getRow(0, 2); | ||
assertEquals(1672498800, rowData.getLong(0)); | ||
assertEquals(123, rowData.getInt(1)); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...rotobuf/src/test/java/org/apache/flink/formats/protobuf/TimestampOuterMultiToRowTest.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.flink.formats.protobuf; | ||
|
||
import org.apache.flink.formats.protobuf.testproto.TestTimestamp.TimestampTest; | ||
import org.apache.flink.formats.protobuf.testproto.TimestampTestOuterMulti; | ||
import org.apache.flink.table.data.RowData; | ||
|
||
import com.google.protobuf.Timestamp; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Test conversion of proto timestamp data with multiple_files and outer_classname options to flink | ||
* internal data. | ||
*/ | ||
public class TimestampOuterMultiToRowTest { | ||
|
||
@Test | ||
public void testSimple() throws Exception { | ||
TimestampTestOuterMulti timestampTestOuterMulti = | ||
TimestampTestOuterMulti.newBuilder() | ||
.setTs(Timestamp.newBuilder().setSeconds(1672498800).setNanos(123)) | ||
.build(); | ||
RowData row = | ||
ProtobufTestHelper.pbBytesToRow( | ||
TimestampTest.class, timestampTestOuterMulti.toByteArray()); | ||
|
||
RowData rowData = row.getRow(0, 2); | ||
assertEquals(1672498800, rowData.getLong(0)); | ||
assertEquals(123, rowData.getInt(1)); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...tobuf/src/test/java/org/apache/flink/formats/protobuf/TimestampOuterNomultiToRowTest.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,47 @@ | ||
/* | ||
* 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.flink.formats.protobuf; | ||
|
||
import org.apache.flink.formats.protobuf.testproto.TestTimestamp.TimestampTest; | ||
import org.apache.flink.formats.protobuf.testproto.TimestampTestOuterNomultiProto; | ||
import org.apache.flink.table.data.RowData; | ||
|
||
import com.google.protobuf.Timestamp; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** Test conversion of proto timestamp data with outer_classname options to flink internal data. */ | ||
public class TimestampOuterNomultiToRowTest { | ||
|
||
@Test | ||
public void testSimple() throws Exception { | ||
TimestampTestOuterNomultiProto.TimestampTestOuterNomulti timestampTestOuterNomulti = | ||
TimestampTestOuterNomultiProto.TimestampTestOuterNomulti.newBuilder() | ||
.setTs(Timestamp.newBuilder().setSeconds(1672498800).setNanos(123)) | ||
.build(); | ||
RowData row = | ||
ProtobufTestHelper.pbBytesToRow( | ||
TimestampTest.class, timestampTestOuterNomulti.toByteArray()); | ||
|
||
RowData rowData = row.getRow(0, 2); | ||
assertEquals(1672498800, rowData.getLong(0)); | ||
assertEquals(123, rowData.getInt(1)); | ||
} | ||
} |
Oops, something went wrong.