You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2018/05/09 20:14:03 UTC
[1/2] phoenix git commit: PHOENIX-4678 ndexScrutinyTool generates
malformed query due to incorrect table name(s) (Josh Elser)
Repository: phoenix
Updated Branches:
refs/heads/4.x-HBase-0.98 f81f4327e -> 68938b856
PHOENIX-4678 ndexScrutinyTool generates malformed query due to incorrect table name(s) (Josh Elser)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/2600c54a
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/2600c54a
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/2600c54a
Branch: refs/heads/4.x-HBase-0.98
Commit: 2600c54abca442b9dfbe1b3f79778786825fd2d3
Parents: f81f432
Author: James Taylor <jt...@salesforce.com>
Authored: Wed May 9 12:50:22 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 12:50:22 2018 -0700
----------------------------------------------------------------------
phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/2600c54a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
index a73467a..153b377 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
@@ -1103,7 +1103,7 @@ public class SchemaUtil {
* @return the byte representation of the HTable
*/
public static String getQualifiedTableName(String schemaName, String tableName) {
- if (schemaName != null) {
+ if (schemaName != null && !schemaName.isEmpty()) {
return String.format("%s.%s", normalizeIdentifier(schemaName),
normalizeIdentifier(tableName));
} else {
[2/2] phoenix git commit: PHOENIX-4646 The data exceeds the max
capacity for the data type error for valid scenarios (Sergey Soldatov)
Posted by ja...@apache.org.
PHOENIX-4646 The data exceeds the max capacity for the data type error for valid scenarios (Sergey Soldatov)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/68938b85
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/68938b85
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/68938b85
Branch: refs/heads/4.x-HBase-0.98
Commit: 68938b856a515503dd5fd45683f7c8d647e7a78a
Parents: 2600c54
Author: James Taylor <jt...@salesforce.com>
Authored: Wed May 9 13:12:26 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 13:12:26 2018 -0700
----------------------------------------------------------------------
.../apache/phoenix/end2end/UpsertSelectIT.java | 19 +++++++++++++++++++
.../apache/phoenix/schema/types/PVarchar.java | 10 ++++++----
2 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/68938b85/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
index 087dadf..e6ca437 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
@@ -1486,6 +1486,25 @@ public class UpsertSelectIT extends ParallelStatsDisabledIT {
}
}
+ @Test // See https://issues.apache.org/jira/browse/PHOENIX-4646
+ public void testLengthLimitedVarchar() throws Exception {
+ String tableName1 = generateUniqueName();
+ String tableName2 = generateUniqueName();
+ try (Connection conn = DriverManager.getConnection(getUrl())) {
+ conn.setAutoCommit(true);
+ conn.createStatement().execute("create table " + tableName1 + "(name varchar(160) primary key, id varchar(120), address varchar(160))");
+ conn.createStatement().execute("create table " + tableName2 + "(name varchar(160) primary key, id varchar(10), address varchar(10))");
+ conn.createStatement().execute("upsert into " + tableName1 + " values('test','test','test')");
+ conn.createStatement().execute("upsert into " + tableName2 + " select * from " + tableName1);
+ ResultSet rs = conn.createStatement().executeQuery("select * from " + tableName2);
+ assertTrue(rs.next());
+ assertEquals("test", rs.getString(1));
+ assertEquals("test", rs.getString(2));
+ assertEquals("test", rs.getString(2));
+ assertFalse(rs.next());
+ }
+ }
+
private static Connection getTenantConnection(String tenantId) throws Exception {
Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
props.setProperty(TENANT_ID_ATTRIB, tenantId);
http://git-wip-us.apache.org/repos/asf/phoenix/blob/68938b85/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
index fb5a045..a99925c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
@@ -102,15 +102,17 @@ public class PVarchar extends PDataType<String> {
SortOrder sortOrder, Integer maxLength, Integer scale,
Integer desiredMaxLength, Integer desiredScale) {
if (ptr.getLength() != 0 && desiredMaxLength != null) {
- if (maxLength == null) {
+ if (maxLength == null || maxLength > desiredMaxLength) {
if (value != null) { // Use value if provided
maxLength = value.toString().length();
} else {
- coerceBytes(ptr, value, srcType, maxLength, scale, sortOrder, desiredMaxLength, desiredScale, sortOrder, true);
- maxLength = StringUtil.calculateUTF8Length(ptr.get(), ptr.getOffset(), ptr.getLength(), sortOrder);
+ coerceBytes(ptr, value, srcType, maxLength, scale, sortOrder, desiredMaxLength,
+ desiredScale, sortOrder, true);
+ maxLength = StringUtil
+ .calculateUTF8Length(ptr.get(), ptr.getOffset(), ptr.getLength(), sortOrder);
}
+ return maxLength <= desiredMaxLength;
}
- return maxLength <= desiredMaxLength;
}
return true;
}