-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
63 changed files
with
656 additions
and
326 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
38 changes: 38 additions & 0 deletions
38
presto-hive-metastore/src/main/java/com/facebook/presto/hive/ColumnConverter.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,38 @@ | ||
/* | ||
* 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. | ||
*/ | ||
package com.facebook.presto.hive; | ||
|
||
import com.facebook.presto.common.type.TypeSignature; | ||
import com.facebook.presto.hive.metastore.Column; | ||
import org.apache.hadoop.hive.metastore.api.FieldSchema; | ||
|
||
import java.util.Optional; | ||
|
||
public interface ColumnConverter | ||
{ | ||
/** | ||
* Converts the provided {@param fieldSchema} to Column | ||
*/ | ||
Column toColumn(FieldSchema fieldSchema); | ||
|
||
/** | ||
* Converts the provided {@param column} to FieldSchema | ||
*/ | ||
FieldSchema fromColumn(Column column); | ||
|
||
/** | ||
* Generates a new TypeSignature using {@param hiveType} and extra {@param typeMetadata} | ||
*/ | ||
TypeSignature getTypeSignature(HiveType hiveType, Optional<String> typeMetadata); | ||
} |
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
50 changes: 50 additions & 0 deletions
50
...-hive-metastore/src/main/java/com/facebook/presto/hive/metastore/HiveColumnConverter.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 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 com.facebook.presto.hive.metastore; | ||
|
||
import com.facebook.presto.common.type.TypeSignature; | ||
import com.facebook.presto.hive.ColumnConverter; | ||
import com.facebook.presto.hive.HiveType; | ||
import org.apache.hadoop.hive.metastore.api.FieldSchema; | ||
|
||
import javax.inject.Inject; | ||
|
||
import java.util.Optional; | ||
|
||
import static com.google.common.base.Strings.emptyToNull; | ||
|
||
public class HiveColumnConverter | ||
implements ColumnConverter | ||
{ | ||
@Inject | ||
public HiveColumnConverter() {} | ||
|
||
@Override | ||
public Column toColumn(FieldSchema fieldSchema) | ||
{ | ||
return new Column(fieldSchema.getName(), HiveType.valueOf(fieldSchema.getType()), Optional.ofNullable(emptyToNull(fieldSchema.getComment())), Optional.empty()); | ||
} | ||
|
||
@Override | ||
public FieldSchema fromColumn(Column column) | ||
{ | ||
return new FieldSchema(column.getName(), column.getType().getHiveTypeName().toString(), column.getComment().orElse(null)); | ||
} | ||
|
||
@Override | ||
public TypeSignature getTypeSignature(HiveType hiveType, Optional<String> typeMetadata) | ||
{ | ||
return hiveType.getTypeSignature(); | ||
} | ||
} |
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
Oops, something went wrong.