Package org.apache.phoenix.util

Examples of org.apache.phoenix.util.ColumnInfo



    @Test
    public void testBuildColumnInfoList() {
        List<ColumnInfo> columnInfoList = ImmutableList.of(
                new ColumnInfo("idCol", PDataType.INTEGER.getSqlType()),
                new ColumnInfo("unsignedIntCol", PDataType.UNSIGNED_INT.getSqlType()),
                new ColumnInfo("stringArrayCol", PDataType.INTEGER_ARRAY.getSqlType()));

        Configuration conf = new Configuration();
        CsvToKeyValueMapper.configureColumnInfoList(conf, columnInfoList);
        List<ColumnInfo> fromConfig = CsvToKeyValueMapper.buildColumnInfoList(conf);
View Full Code Here


    @Test
    public void testBuildColumnInfoList_ContainingNulls() {
        // A null value in the column info list means "skip that column in the input"
        List<ColumnInfo> columnInfoListWithNull = Lists.newArrayList(
                new ColumnInfo("idCol", PDataType.INTEGER.getSqlType()),
                null,
                new ColumnInfo("unsignedIntCol", PDataType.UNSIGNED_INT.getSqlType()),
                new ColumnInfo("stringArrayCol", PDataType.INTEGER_ARRAY.getSqlType()));

        Configuration conf = new Configuration();
        CsvToKeyValueMapper.configureColumnInfoList(conf, columnInfoListWithNull);
        List<ColumnInfo> fromConfig = CsvToKeyValueMapper.buildColumnInfoList(conf);
View Full Code Here

        String tableName = "SCHEMANAME.TABLENAME";
        char delimiter = '!';

        List<ColumnInfo> columnInfoList = ImmutableList.of(
                new ColumnInfo("MYCOL", PDataType.INTEGER.getSqlType()));

        CsvBulkImportUtil.initCsvImportJob(
                conf, tableName, delimiter, null, columnInfoList, true);

        assertEquals(tableName, conf.get(CsvToKeyValueMapper.TABLE_NAME_CONFKEY));
View Full Code Here

    private CsvUpsertExecutor upsertExecutor;

    @Before
    public void setUp() throws SQLException {
        columnInfoList = ImmutableList.of(
                new ColumnInfo("ID", Types.BIGINT),
                new ColumnInfo("NAME", Types.VARCHAR),
                new ColumnInfo("AGE", Types.INTEGER),
                new ColumnInfo("VALUES", PDataType.INTEGER_ARRAY.getSqlType()));

        preparedStatement = mock(PreparedStatement.class);
        upsertListener = mock(CsvUpsertExecutor.UpsertListener.class);
        conn = DriverManager.getConnection(getUrl());
        upsertExecutor = new CsvUpsertExecutor(conn, columnInfoList, preparedStatement, upsertListener, ":");
View Full Code Here

                Integer sqlType = unqualifiedColumnMap.get(rowkey);
                if (sqlType == null) {
                    throw new SQLExceptionInfo.Builder(SQLExceptionCode.PRIMARY_KEY_MISSING)
                         .setColumnName(rowkey).setTableName(fullTableName).build().buildException();
                }
                columnMetadata[position] = new ColumnInfo(rowkey, sqlType);
                position++;
            }
           
            this.upsertStatement = QueryUtil.constructUpsertStatement(fullTableName, Arrays.asList(columnMetadata));
            logger.info(" the upsert statement is {} " ,this.upsertStatement);
View Full Code Here

                if (sqlType == null) {
                   throw new SQLExceptionInfo.Builder(SQLExceptionCode.COLUMN_NOT_FOUND)
                        .setColumnName(columnName).setTableName(this.fullTableName).build().buildException();
                }
            }
            columnMetadata[position] = new ColumnInfo(columnName, sqlType);
            position++;
       }
       return position;
    }
View Full Code Here

            final List<? extends ColumnProjector> projectedColumns = queryPlan.getProjector().getColumnProjectors();
            columnInfos = Lists.newArrayListWithCapacity(projectedColumns.size());
            columnInfos = Lists.transform(projectedColumns, new Function<ColumnProjector,ColumnInfo>() {
              @Override
        public ColumnInfo apply(final ColumnProjector columnProjector) {
          return new ColumnInfo(columnProjector.getName(), columnProjector.getExpression().getDataType().getSqlType());
        }
             
            });
     } catch (SQLException e) {
            LOG.error(String.format(" Error [%s] parsing SELECT query [%s] ",e.getMessage(),sqlQuery));
View Full Code Here

  }
 
  public void write(PreparedStatement statement, List<ColumnInfo> columnMetadataList) throws SQLException {
    for (int i = 0; i < columnMetadataList.size(); i++) {
      Object o = values.get(i);
      ColumnInfo columnInfo = columnMetadataList.get(i);
      byte type = (fieldSchemas == null) ? DataType.findType(o) : fieldSchemas[i].getType();
      try {
                Object upsertValue = convertTypeSpecificValue(o, type, columnInfo.getSqlType());
                if (upsertValue != null) {
                    statement.setObject(i + 1, upsertValue, columnInfo.getSqlType());
                } else {
                    statement.setNull(i + 1, columnInfo.getSqlType());
                }
            } catch (RuntimeException re) {
                throw new RuntimeException(String.format("Unable to process column %s, innerMessage=%s"
                        ,columnInfo.toString(),re.getMessage()),re);
               
            }
    }
   
    statement.execute();
View Full Code Here

*/
public class ColumnInfoToStringEncoderDecoderTest {

    @Test
    public void testEncode() {
        final ColumnInfo columnInfo = new ColumnInfo("col1", PDataType.VARCHAR.getSqlType());
        final String encodedColumnInfo = ColumnInfoToStringEncoderDecoder.encode(Lists.newArrayList(columnInfo));
        assertEquals(columnInfo.toString(),encodedColumnInfo);
    }
View Full Code Here

        assertEquals(columnInfo.toString(),encodedColumnInfo);
    }
   
    @Test
    public void testDecode() {
        final ColumnInfo columnInfo = new ColumnInfo("col1", PDataType.VARCHAR.getSqlType());
        final String encodedColumnInfo = ColumnInfoToStringEncoderDecoder.encode(Lists.newArrayList(columnInfo));
        assertEquals(columnInfo.toString(),encodedColumnInfo);
    }
View Full Code Here

TOP

Related Classes of org.apache.phoenix.util.ColumnInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.