/** * Set the column projection column names from CarbonProjection * * @param configuration Configuration info * @param projection CarbonProjection object that includes unique projection column name */ public static void setColumnProjection(Configuration configuration, CarbonProjection projection) { if (projection == null || projection.isEmpty()) { return; } String[] allColumns = projection.getAllColumns(); StringBuilder builder = new StringBuilder(); for (String column : allColumns) { builder.append(column).append(","); } String columnString = builder.toString(); columnString = columnString.substring(0, columnString.length() - 1); configuration.set(COLUMN_PROJECTION, columnString); }
CarbonInputFormat.setCarbonReadSupport(job.getConfiguration(), CarbonRowReadSupport.class); CarbonInputFormat .setColumnProjection(job.getConfiguration(), new CarbonProjection(projectColumns)); if (filter != null) { CarbonInputFormat.setFilterPredicates(job.getConfiguration(), filter);
public static <V> CarbonTableInputFormat<V> createCarbonTableInputFormat( Job job, CarbonTable carbonTable, String[] projectionColumns, Expression filterExpression, List<PartitionSpec> partitionNames, DataMapJob dataMapJob) throws IOException, InvalidConfigurationException { Configuration conf = job.getConfiguration(); CarbonInputFormat.setTableInfo(conf, carbonTable.getTableInfo()); CarbonInputFormat.setDatabaseName(conf, carbonTable.getTableInfo().getDatabaseName()); CarbonInputFormat.setTableName(conf, carbonTable.getTableInfo().getFactTable().getTableName()); if (partitionNames != null) { CarbonInputFormat.setPartitionsToPrune(conf, partitionNames); } CarbonInputFormat .setTransactionalTable(conf, carbonTable.getTableInfo().isTransactionalTable()); CarbonProjection columnProjection = new CarbonProjection(projectionColumns); return createInputFormat(conf, carbonTable.getAbsoluteTableIdentifier(), filterExpression, columnProjection, dataMapJob); }