if(message.hasCatalogName()) output.writeString(1, message.getCatalogName(), false); if(message.hasSchemaName()) output.writeString(2, message.getSchemaName(), false); if(message.hasTableName()) output.writeString(3, message.getTableName(), false); if(message.hasColumnName()) output.writeString(4, message.getColumnName(), false); if(message.hasOrdinalPosition()) output.writeInt32(5, message.getOrdinalPosition(), false); if(message.hasDefaultValue()) output.writeString(6, message.getDefaultValue(), false); if(message.hasIsNullable()) output.writeBool(7, message.getIsNullable(), false); if(message.hasDataType()) output.writeString(8, message.getDataType(), false); if(message.hasCharMaxLength()) output.writeInt32(9, message.getCharMaxLength(), false); if(message.hasCharOctetLength()) output.writeInt32(10, message.getCharOctetLength(), false); if(message.hasNumericPrecision()) output.writeInt32(11, message.getNumericPrecision(), false); if(message.hasNumericPrecisionRadix()) output.writeInt32(12, message.getNumericPrecisionRadix(), false); if(message.hasNumericScale()) output.writeInt32(13, message.getNumericScale(), false); if(message.hasDateTimePrecision()) output.writeInt32(14, message.getDateTimePrecision(), false); if(message.hasIntervalType())
private int getDataType(ColumnMetadata value) { switch (value.getDataType()) { case "ARRAY": return Types.ARRAY;
public Builder mergeFrom(org.apache.drill.exec.proto.UserProtos.ColumnMetadata other) { if (other == org.apache.drill.exec.proto.UserProtos.ColumnMetadata.getDefaultInstance()) return this; if (other.hasCatalogName()) { bitField0_ |= 0x00000001; catalogName_ = other.catalogName_; onChanged(); if (other.hasSchemaName()) { bitField0_ |= 0x00000002; schemaName_ = other.schemaName_; onChanged(); if (other.hasTableName()) { bitField0_ |= 0x00000004; tableName_ = other.tableName_; onChanged(); if (other.hasColumnName()) { bitField0_ |= 0x00000008; columnName_ = other.columnName_; onChanged(); if (other.hasOrdinalPosition()) { setOrdinalPosition(other.getOrdinalPosition()); if (other.hasDefaultValue()) { bitField0_ |= 0x00000020; defaultValue_ = other.defaultValue_; onChanged();
Integer getDecimalDigits(ColumnMetadata value) { switch(value.getDataType()) { case "TINYINT": case "SMALLINT": case "INTEGER": case "BIGINT": case "DECIMAL": case "NUMERIC": return value.hasNumericScale() ? value.getNumericScale() : null; case "REAL": return DECIMAL_DIGITS_REAL; case "FLOAT": return DECIMAL_DIGITS_FLOAT; case "DOUBLE": return DECIMAL_DIGITS_DOUBLE; case "DATE": case "TIME": case "TIMESTAMP": case "INTERVAL": return value.getDateTimePrecision(); default: return null; } }
private Integer getNumPrecRadix(ColumnMetadata value) { switch(value.getDataType()) { case "TINYINT": case "SMALLINT": case "INTEGER": case "BIGINT": case "DECIMAL": case "NUMERIC": case "REAL": case "FLOAT": case "DOUBLE": return value.getNumericPrecisionRadix(); case "INTERVAL": return RADIX_INTERVAL; case "DATE": case "TIME": case "TIMESTAMP": return RADIX_DATETIME; default: return null; } }
private Integer getCharOctetLength(ColumnMetadata value) { if (!value.hasCharMaxLength()) { return null; } switch(value.getDataType()) { case "CHARACTER": case "CHARACTER LARGE OBJECT": case "CHARACTER VARYING": case "LONGVARCHAR": case "LONGNVARCHAR": case "NATIONAL CHARACTER": case "NATIONAL CHARACTER LARGE OBJECT": case "NATIONAL CHARACTER VARYING": return value.getCharOctetLength(); default: return null; } }
@Override protected MetaColumn adapt(ColumnMetadata value) { return new MetaColumn( value.getCatalogName(), value.getSchemaName(), value.getTableName(), value.getColumnName(), getDataType(value), // It might require the full SQL type value.getDataType(), value.getColumnSize(), getDecimalDigits(value), getNumPrecRadix(value), getNullable(value), getCharOctetLength(value), value.getOrdinalPosition(), getIsNullable(value)); } }.getMeta(connection.getClient().getColumns(catalogNameFilter, schemaNameFilter, tableNameFilter, columnNameFilter));
/** * <code>optional string data_type = 8;</code> */ public Builder clearDataType() { bitField0_ = (bitField0_ & ~0x00000080); dataType_ = getDefaultInstance().getDataType(); onChanged(); return this; } /**
/** * <code>optional string column_name = 4;</code> */ public Builder clearColumnName() { bitField0_ = (bitField0_ & ~0x00000008); columnName_ = getDefaultInstance().getColumnName(); onChanged(); return this; } /**
private int getNullable(ColumnMetadata value) { if (!value.hasIsNullable()) { return DatabaseMetaData.columnNullableUnknown; } return value.getIsNullable() ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls; }
/** * <code>optional string catalog_name = 1;</code> */ public Builder clearCatalogName() { bitField0_ = (bitField0_ & ~0x00000001); catalogName_ = getDefaultInstance().getCatalogName(); onChanged(); return this; } /**
private String getIsNullable(ColumnMetadata value) { if (!value.hasIsNullable()) { return ""; } return value.getIsNullable() ? "YES" : "NO"; }
/** * <code>optional string schema_name = 2;</code> */ public Builder clearSchemaName() { bitField0_ = (bitField0_ & ~0x00000002); schemaName_ = getDefaultInstance().getSchemaName(); onChanged(); return this; } /**
/** * <code>optional string table_name = 3;</code> */ public Builder clearTableName() { bitField0_ = (bitField0_ & ~0x00000004); tableName_ = getDefaultInstance().getTableName(); onChanged(); return this; } /**
@Override public int compare(ColumnMetadata left, ColumnMetadata right) { return ComparisonChain.start() .compare(left.getCatalogName(), right.getCatalogName()) .compare(left.getSchemaName(), right.getSchemaName()) .compare(left.getTableName(), right.getTableName()) .compare(left.getOrdinalPosition(), right.getOrdinalPosition()) .result(); } };
private int getDataType(ColumnMetadata value) { switch (value.getDataType()) { case "ARRAY": return Types.ARRAY;
public Builder mergeFrom(org.apache.drill.exec.proto.UserProtos.ColumnMetadata other) { if (other == org.apache.drill.exec.proto.UserProtos.ColumnMetadata.getDefaultInstance()) return this; if (other.hasCatalogName()) { bitField0_ |= 0x00000001; catalogName_ = other.catalogName_; onChanged(); if (other.hasSchemaName()) { bitField0_ |= 0x00000002; schemaName_ = other.schemaName_; onChanged(); if (other.hasTableName()) { bitField0_ |= 0x00000004; tableName_ = other.tableName_; onChanged(); if (other.hasColumnName()) { bitField0_ |= 0x00000008; columnName_ = other.columnName_; onChanged(); if (other.hasOrdinalPosition()) { setOrdinalPosition(other.getOrdinalPosition()); if (other.hasDefaultValue()) { bitField0_ |= 0x00000020; defaultValue_ = other.defaultValue_; onChanged();
if(message.hasCatalogName()) output.writeString(1, message.getCatalogName(), false); if(message.hasSchemaName()) output.writeString(2, message.getSchemaName(), false); if(message.hasTableName()) output.writeString(3, message.getTableName(), false); if(message.hasColumnName()) output.writeString(4, message.getColumnName(), false); if(message.hasOrdinalPosition()) output.writeInt32(5, message.getOrdinalPosition(), false); if(message.hasDefaultValue()) output.writeString(6, message.getDefaultValue(), false); if(message.hasIsNullable()) output.writeBool(7, message.getIsNullable(), false); if(message.hasDataType()) output.writeString(8, message.getDataType(), false); if(message.hasCharMaxLength()) output.writeInt32(9, message.getCharMaxLength(), false); if(message.hasCharOctetLength()) output.writeInt32(10, message.getCharOctetLength(), false); if(message.hasNumericPrecision()) output.writeInt32(11, message.getNumericPrecision(), false); if(message.hasNumericPrecisionRadix()) output.writeInt32(12, message.getNumericPrecisionRadix(), false); if(message.hasNumericScale()) output.writeInt32(13, message.getNumericScale(), false); if(message.hasDateTimePrecision()) output.writeInt32(14, message.getDateTimePrecision(), false); if(message.hasIntervalType())
Integer getDecimalDigits(ColumnMetadata value) { switch(value.getDataType()) { case "TINYINT": case "SMALLINT": case "INTEGER": case "BIGINT": case "DECIMAL": case "NUMERIC": return value.hasNumericScale() ? value.getNumericScale() : null; case "REAL": return DECIMAL_DIGITS_REAL; case "FLOAT": return DECIMAL_DIGITS_FLOAT; case "DOUBLE": return DECIMAL_DIGITS_DOUBLE; case "DATE": case "TIME": case "TIMESTAMP": case "INTERVAL": return value.getDateTimePrecision(); default: return null; } }
private Integer getNumPrecRadix(ColumnMetadata value) { switch(value.getDataType()) { case "TINYINT": case "SMALLINT": case "INTEGER": case "BIGINT": case "DECIMAL": case "NUMERIC": case "REAL": case "FLOAT": case "DOUBLE": return value.getNumericPrecisionRadix(); case "INTERVAL": return RADIX_INTERVAL; case "DATE": case "TIME": case "TIMESTAMP": return RADIX_DATETIME; default: return null; } }