Package org.apache.phoenix.util

Examples of org.apache.phoenix.util.ColumnInfo


        assertEquals(columnInfo.toString(),encodedColumnInfo);
    }
   
    @Test
    public void testEncodeDecodeWithNulls() {
        final ColumnInfo columnInfo1 = new ColumnInfo("col1", PDataType.VARCHAR.getSqlType());
        final ColumnInfo columnInfo2 = null;
        final String columnInfoStr = ColumnInfoToStringEncoderDecoder.encode(Lists.newArrayList(columnInfo1,columnInfo2));
        final List<ColumnInfo> decodedColumnInfo = ColumnInfoToStringEncoderDecoder.decode(columnInfoStr);
        assertEquals(1,decodedColumnInfo.size());
    }
View Full Code Here


                "  (id integer not null, name varchar, age integer,location varchar " +
                "  CONSTRAINT pk PRIMARY KEY (id))\n";
        createTestTable(getUrl(), ddl);
 
        final String selectQuery = "SELECT name as a ,age AS b,UPPER(location) AS c FROM EMPLOYEE";
        final ColumnInfo NAME_COLUMN = new ColumnInfo("A", Types.VARCHAR);
        final ColumnInfo AGE_COLUMN = new ColumnInfo("B", Types.INTEGER);
        final ColumnInfo LOCATION_COLUMN = new ColumnInfo("C", Types.VARCHAR);
        final List<ColumnInfo> expectedColumnInfos = ImmutableList.of(NAME_COLUMN, AGE_COLUMN,LOCATION_COLUMN);
        final List<ColumnInfo> actualColumnInfos = function.apply(selectQuery);
        Assert.assertEquals(expectedColumnInfos, actualColumnInfos);
       
    }
View Full Code Here

    if (columnMetadataList == null) {
      columnMetadataList = new ArrayList<ColumnInfo>();
      String[] tableMetadata = getTableMetadata(getTableName());
      ResultSet rs = conn.getMetaData().getColumns(null, tableMetadata[0], tableMetadata[1], null);
      while (rs.next()) {
        columnMetadataList.add(new ColumnInfo(rs.getString(QueryUtil.COLUMN_NAME_POSITION), rs.getInt(QueryUtil.DATA_TYPE_POSITION)));
      }
    }
   
    // Generating UPSERT statement without column name information.
    String upsertStmt = QueryUtil.constructUpsertStatement(null, getTableName(), columnMetadataList.size());
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

    if (columnMetadataList == null) {
      columnMetadataList = new ArrayList<ColumnInfo>();
      String[] tableMetadata = getTableMetadata(getTableName());
      ResultSet rs = conn.getMetaData().getColumns(null, tableMetadata[0], tableMetadata[1], null);
      while (rs.next()) {
        columnMetadataList.add(new ColumnInfo(rs.getString(QueryUtil.COLUMN_NAME_POSITION), rs.getInt(QueryUtil.DATA_TYPE_POSITION)));
      }
    }
   
    // Generating UPSERT statement without column name information.
    String upsertStmt = QueryUtil.constructGenericUpsertStatement(getTableName(), columnMetadataList.size());
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.