This is an automated email from the ASF dual-hosted git repository.

stoty pushed a commit to branch 5.1
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/5.1 by this push:
     new 5451ce0e88 PHOENIX-6773 PhoenixDatabaseMetadata.getColumns() always 
returns null COLUMN_DEF
5451ce0e88 is described below

commit 5451ce0e88ec46597bed3fed18951e7260e67e31
Author: Aron Meszaros <[email protected]>
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 de50b35a7d..7ab175c3be 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
@@ -477,6 +477,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"));
@@ -490,6 +491,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 4866d4050b..abd553e922 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
@@ -821,7 +821,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,

Reply via email to