dybyte commented on code in PR #9812:
URL: https://github.com/apache/seatunnel/pull/9812#discussion_r2319296462
##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/ArrayType.java:
##########
@@ -61,6 +66,35 @@ public ArrayType(Class<T> arrayClass, SeaTunnelDataType<E>
elementType) {
this.elementType = elementType;
}
+ @SuppressWarnings("unchecked")
+ public static <E> ArrayType<E[], E> of(SeaTunnelDataType<E> elementType) {
+ if (elementType == null) {
+ throw CommonError.illegalArgument("elementType is null",
OPERATION);
+ }
+ Class<E[]> arrayClass = (Class<E[]>) toArrayClass(elementType);
+ return new ArrayType<>(arrayClass, elementType);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <E> ArrayType<?, ?> of(SeaTunnelDataType<E> elementType, int
dimensions) {
+ if (dimensions < 1) {
+ throw CommonError.illegalArgument("dimensions must be >= 1",
OPERATION);
+ }
+ SeaTunnelDataType<?> current = elementType;
+ for (int i = 0; i < dimensions; i++) {
+ current = of(current);
+ }
+ return (ArrayType<?, ?>) current;
+ }
+
+ public ArrayType<T[], T> addDimension() {
+ return ArrayType.of(this);
+ }
+
+ public int getDimensions() {
+ return dimensionOf(arrayClass);
+ }
Review Comment:
Ok. Closing this PR for now, feel free to reopen it if we need these helpers
in the future.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]