Github user prashantkommireddi commented on a diff in the pull request:
https://github.com/apache/incubator-phoenix/pull/22#discussion_r10852673
--- Diff: phoenix-pig/src/main/java/org/apache/phoenix/pig/TypeUtil.java ---
@@ -185,5 +194,85 @@ public static Object castBytes(Object o, PDataType
targetPhoenixType) throws IOE
return o;
}
}
+
+ public static Tuple transformToTuple(final PhoenixRecord record, final
List<? extends ColumnProjector> projectedColumns) throws IOException {
+
+ List<Object> columnValues = record.getValues();
+ if(columnValues == null || columnValues.size() == 0 ||
projectedColumns == null || projectedColumns.size() != columnValues.size()) {
+ return null;
+ }
+ int columns = columnValues.size();
+ Tuple _tuple = TupleFactory.getInstance().newTuple(columns);
+ try {
+ for (int i = 0 ; i < columns ; i++) {
+ ColumnProjector projector = projectedColumns.get(i);
+ Integer type =
projector.getExpression().getDataType().getSqlType();
+ Object obj = columnValues.get(i);
+
+ if (obj == null) {
+ _tuple.set(i, null);
+ continue;
+ }
+
+ switch (type) {
--- End diff --
Store does the opposite of this, it converts Pig types to Phoenix types.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---