-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extended QPT To Datalakegen2 (#1822)
Co-authored-by: AbdulRehman Faraj <[email protected]> Co-authored-by: Jithendar Trianz <[email protected]>
- Loading branch information
1 parent
944e3a9
commit 9f3ad72
Showing
5 changed files
with
169 additions
and
46 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
...gen2/src/main/java/com/amazonaws/athena/connectors/datalakegen2/DataLakeGen2DataType.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,60 @@ | ||
/*- | ||
* #%L | ||
* athena-datalakegen2 | ||
* %% | ||
* Copyright (C) 2019 - 2024 Amazon Web Services | ||
* %% | ||
* Licensed 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. | ||
* #L% | ||
*/ | ||
package com.amazonaws.athena.connectors.datalakegen2; | ||
|
||
import org.apache.arrow.vector.types.Types; | ||
import org.apache.arrow.vector.types.pojo.ArrowType; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum DataLakeGen2DataType { | ||
BIT(Types.MinorType.TINYINT.getType()), | ||
TINYINT(Types.MinorType.SMALLINT.getType()), | ||
NUMERIC(Types.MinorType.FLOAT8.getType()), | ||
SMALLMONEY(Types.MinorType.FLOAT8.getType()), | ||
DATE(Types.MinorType.DATEDAY.getType()), | ||
DATETIME(Types.MinorType.DATEMILLI.getType()), | ||
DATETIME2(Types.MinorType.DATEMILLI.getType()), | ||
SMALLDATETIME(Types.MinorType.DATEMILLI.getType()), | ||
DATETIMEOFFSET(Types.MinorType.DATEMILLI.getType()); | ||
|
||
private ArrowType arrowType; | ||
|
||
DataLakeGen2DataType(ArrowType arrowType) | ||
{ | ||
this.arrowType = arrowType; | ||
} | ||
|
||
public static ArrowType fromType(String gen2Type) | ||
{ | ||
DataLakeGen2DataType result = DataLakeGen2DataType.valueOf(gen2Type.toUpperCase()); | ||
return result.arrowType; | ||
} | ||
|
||
public static boolean isSupported(String dataType) | ||
{ | ||
return Arrays.stream(values()).anyMatch(value -> value.name().equalsIgnoreCase(dataType)); | ||
} | ||
|
||
public ArrowType getArrowType() | ||
{ | ||
return this.arrowType; | ||
} | ||
} |
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
56 changes: 56 additions & 0 deletions
56
.../src/test/java/com/amazonaws/athena/connectors/datalakegen2/DataLakeGen2DataTypeTest.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,56 @@ | ||
/*- | ||
* #%L | ||
* athena-datalakegen2 | ||
* %% | ||
* Copyright (C) 2019 - 2024 Amazon Web Services | ||
* %% | ||
* Licensed 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. | ||
* #L% | ||
*/ | ||
package com.amazonaws.athena.connectors.datalakegen2; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class DataLakeGen2DataTypeTest { | ||
|
||
@Test | ||
void isSupported() { | ||
assertTrue(DataLakeGen2DataType.isSupported("bit")); | ||
assertTrue(DataLakeGen2DataType.isSupported("TINYINT")); | ||
assertTrue(DataLakeGen2DataType.isSupported("NUMERIC")); | ||
assertTrue(DataLakeGen2DataType.isSupported("SMALLMONEY")); | ||
assertTrue(DataLakeGen2DataType.isSupported("DATE")); | ||
assertTrue(DataLakeGen2DataType.isSupported("DATETIME")); | ||
assertTrue(DataLakeGen2DataType.isSupported("DATETIME2")); | ||
assertTrue(DataLakeGen2DataType.isSupported("SMALLDATETIME")); | ||
assertTrue(DataLakeGen2DataType.isSupported("DATETIMEOFFSET")); | ||
|
||
assertFalse(DataLakeGen2DataType.isSupported("unknownType")); | ||
} | ||
|
||
@Test | ||
void fromType() | ||
{ | ||
assertEquals(DataLakeGen2DataType.BIT.getArrowType(), DataLakeGen2DataType.fromType("BIT")); | ||
assertEquals(DataLakeGen2DataType.TINYINT.getArrowType(), DataLakeGen2DataType.fromType("TINYINT")); | ||
assertEquals(DataLakeGen2DataType.NUMERIC.getArrowType(), DataLakeGen2DataType.fromType("NUMERIC")); | ||
assertEquals(DataLakeGen2DataType.SMALLMONEY.getArrowType(), DataLakeGen2DataType.fromType("SMALLMONEY")); | ||
assertEquals(DataLakeGen2DataType.DATE.getArrowType(), DataLakeGen2DataType.fromType("DATE")); | ||
assertEquals(DataLakeGen2DataType.DATETIME.getArrowType(), DataLakeGen2DataType.fromType("DATETIME")); | ||
assertEquals(DataLakeGen2DataType.DATETIME2.getArrowType(), DataLakeGen2DataType.fromType("DATETIME2")); | ||
assertEquals(DataLakeGen2DataType.SMALLDATETIME.getArrowType(), DataLakeGen2DataType.fromType("SMALLDATETIME")); | ||
assertEquals(DataLakeGen2DataType.DATETIMEOFFSET.getArrowType(), DataLakeGen2DataType.fromType("DATETIMEOFFSET")); | ||
} | ||
} |
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