>From Peeyush Gupta <[email protected]>:

Peeyush Gupta has submitted this change. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17746 )

Change subject: [NO ISSUE][COMP] Show proper error message with invalid type
......................................................................

[NO ISSUE][COMP] Show proper error message with invalid type

- user model changes: no
- storage format changes: no
- interface changes: no

Details:
While creating dataset without type spec, if a invalid type is used,
a null pointer exception was shown. With this patch we now show a proper
error message.

Change-Id: I7edfe4f52c20da7f667c9560edea50fd7112932f
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17746
Integration-Tests: Jenkins <[email protected]>
Tested-by: Jenkins <[email protected]>
Reviewed-by: Peeyush Gupta <[email protected]>
Reviewed-by: Ali Alsuliman <[email protected]>
---
M 
asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java
1 file changed, 31 insertions(+), 0 deletions(-)

Approvals:
  Ali Alsuliman: Looks good to me, approved
  Peeyush Gupta: Looks good to me, but someone else must approve
  Jenkins: Verified; Verified




diff --git 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java
 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java
index 967f99f..77c1a9d 100644
--- 
a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java
+++ 
b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java
@@ -146,6 +146,10 @@
                     String typeName =
                             ((TypeReferenceExpression) 
partitioningExprTypes.get(0)).getIdent().second.getValue();
                     fieldType = BuiltinTypeMap.getBuiltinType(typeName);
+                    if (fieldType == null) {
+                        throw new 
CompilationException(ErrorCode.COMPILATION_ILLEGAL_KEY_TYPE, sourceLoc, 
typeName,
+                                keyKindDisplayName);
+                    }
                 } else {
                     String unTypeField = fieldName.get(0) == null ? "" : 
fieldName.get(0);
                     throw new 
CompilationException(ErrorCode.COMPILATION_FIELD_NOT_FOUND, sourceLoc,
@@ -170,6 +174,10 @@
                     String typeName =
                             ((TypeReferenceExpression) 
partitioningExprTypes.get(i)).getIdent().second.getValue();
                     fieldType = BuiltinTypeMap.getBuiltinType(typeName);
+                    if (fieldType == null) {
+                        throw new 
CompilationException(ErrorCode.COMPILATION_ILLEGAL_KEY_TYPE, sourceLoc, 
typeName,
+                                keyKindDisplayName);
+                    }
                     computedPartitioningExprTypes.add(fieldType);
                 } else {
                     fieldType = computedPartitioningExprTypes.get(i);

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/17746
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: I7edfe4f52c20da7f667c9560edea50fd7112932f
Gerrit-Change-Number: 17746
Gerrit-PatchSet: 3
Gerrit-Owner: Peeyush Gupta <[email protected]>
Gerrit-Reviewer: Ali Alsuliman <[email protected]>
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Murtadha Al Hubail <[email protected]>
Gerrit-Reviewer: Peeyush Gupta <[email protected]>
Gerrit-MessageType: merged

Reply via email to