You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by st...@apache.org on 2022/09/22 09:04:49 UTC
[phoenix] branch master updated: PHOENIX-6773 PhoenixDatabaseMetadata.getColumns() always returns null COLUMN_DEF
This is an automated email from the ASF dual-hosted git repository.
stoty pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/master by this push:
new 0c2008ddf3 PHOENIX-6773 PhoenixDatabaseMetadata.getColumns() always returns null COLUMN_DEF
0c2008ddf3 is described below
commit 0c2008ddf32566c525df26cb94d60be32acc10da
Author: Aron Meszaros <am...@cloudera.com>
AuthorDate: Wed Sep 21 10:07:10 2022 +0200
PHOENIX-6773 PhoenixDatabaseMetadata.getColumns() always returns null COLUMN_DEF
---
.../it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java | 4 +++-
.../main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java | 3 ++-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
index 6756dbf5bf..cc5b3d511f 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/QueryDatabaseMetaDataIT.java
@@ -92,7 +92,7 @@ public class QueryDatabaseMetaDataIT extends ParallelStatsDisabledIT {
throws SQLException {
String ddl =
"create table if not exists " + tableName + " (id char(1) primary key,\n"
- + " a.col1 integer,\n" + " b.col2 bigint,\n" + " b.col3 decimal,\n"
+ + " a.col1 integer default 42,\n" + " b.col2 bigint,\n" + " b.col3 decimal,\n"
+ " b.col4 decimal(5),\n" + " b.col5 decimal(6,3))\n" + " a."
+ HConstants.VERSIONS + "=" + 1 + "," + "a."
+ ColumnFamilyDescriptorBuilder.DATA_BLOCK_ENCODING + "='" + DataBlockEncoding.NONE
@@ -481,6 +481,7 @@ public class QueryDatabaseMetaDataIT extends ParallelStatsDisabledIT {
assertEquals(table, rs.getString("TABLE_NAME"));
assertEquals(SchemaUtil.normalizeIdentifier("a"), rs.getString("COLUMN_FAMILY"));
assertEquals(SchemaUtil.normalizeIdentifier("col1"), rs.getString("COLUMN_NAME"));
+ assertEquals("42", rs.getString("COLUMN_DEF"));
assertEquals(DatabaseMetaData.attributeNullable, rs.getShort("NULLABLE"));
assertEquals(PInteger.INSTANCE.getSqlType(), rs.getInt("DATA_TYPE"));
assertEquals(2, rs.getInt("ORDINAL_POSITION"));
@@ -494,6 +495,7 @@ public class QueryDatabaseMetaDataIT extends ParallelStatsDisabledIT {
assertEquals(table, rs.getString("TABLE_NAME"));
assertEquals(SchemaUtil.normalizeIdentifier("b"), rs.getString("COLUMN_FAMILY"));
assertEquals(SchemaUtil.normalizeIdentifier("col2"), rs.getString("COLUMN_NAME"));
+ assertEquals(null, rs.getString("COLUMN_DEF"));
assertEquals(DatabaseMetaData.attributeNullable, rs.getShort("NULLABLE"));
assertEquals(PLong.INSTANCE.getSqlType(), rs.getInt("DATA_TYPE"));
assertEquals(3, rs.getInt("ORDINAL_POSITION"));
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
index b345ae6ceb..478a0aa874 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
@@ -852,7 +852,8 @@ public class PhoenixDatabaseMetaData implements DatabaseMetaData {
cells.add(
PhoenixKeyValueUtil.newKeyValue(rowKey, TABLE_FAMILY_BYTES,
Bytes.toBytes(COLUMN_DEF),
- MetaDataProtocol.MIN_TABLE_TIMESTAMP, ByteUtil.EMPTY_BYTE_ARRAY));
+ MetaDataProtocol.MIN_TABLE_TIMESTAMP,
+ PVarchar.INSTANCE.toBytes(column.getExpressionStr())));
// SQL_DATA_TYPE
cells.add(PhoenixKeyValueUtil.newKeyValue(rowKey, TABLE_FAMILY_BYTES,
Bytes.toBytes(SQL_DATA_TYPE), MetaDataProtocol.MIN_TABLE_TIMESTAMP,