Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ql/src/java/org/apache/hadoop/hive/ql/exec/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,10 @@ public static List<String> getColumnNamesFromFieldSchema(List<FieldSchema> partC
return names;
}

public static List<String> getColumnTypesFromFieldSchema(List<FieldSchema> fieldSchemas) {
return fieldSchemas.stream().map(FieldSchema::getType).toList();
}

public static List<String> getInternalColumnNamesFromSignature(List<ColumnInfo> colInfos) {
List<String> names = new ArrayList<String>();
for (ColumnInfo ci : colInfos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.hadoop.hive.ql.parse;

import java.io.IOException;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -1413,11 +1414,54 @@ public String toString() {
}
}

/**
* Holds table column {@link FieldSchema} entries and lazily derived parallel name/type string
* lists for analyze / column-stats compilation.
*/
public static final class FieldSchemas implements Serializable {

private static final long serialVersionUID = 1L;

private final List<FieldSchema> schemas;

private transient List<String> colNames;
private transient List<String> colTypes;

public FieldSchemas(List<FieldSchema> schemas) {
this.schemas = schemas != null ? schemas : Collections.emptyList();
}

public List<FieldSchema> getSchemas() {
return schemas;
}

public int size() {
return schemas.size();
}

public FieldSchema get(int index) {
return schemas.get(index);
}

public List<String> getColName() {
if (colNames == null) {
colNames = Utilities.getColumnNamesFromFieldSchema(schemas);
}
return colNames;
}

public List<String> getColType() {
if (colTypes == null) {
colTypes = Utilities.getColumnTypesFromFieldSchema(schemas);
}
return colTypes;
}
}

public static class AnalyzeRewriteContext {

private String tableName;
private List<String> colName;
private List<String> colType;
private FieldSchemas fieldSchemas;
private boolean tblLvl;

public String getTableName() {
Expand All @@ -1428,12 +1472,12 @@ public void setTableName(String tableName) {
this.tableName = tableName;
}

public List<String> getColName() {
return colName;
public FieldSchemas getFieldSchemas() {
return fieldSchemas;
}

public void setColName(List<String> colName) {
this.colName = colName;
public void setFieldSchemas(FieldSchemas fieldSchemas) {
this.fieldSchemas = fieldSchemas;
}

public boolean isTblLvl() {
Expand All @@ -1444,14 +1488,6 @@ public void setTblLvl(boolean isTblLvl) {
this.tblLvl = isTblLvl;
}

public List<String> getColType() {
return colType;
}

public void setColType(List<String> colType) {
this.colType = colType;
}

}

/**
Expand Down
Loading
Loading