Skip to content

Commit

Permalink
[IOTDB-4424] Specify error message when time value of insert sql can …
Browse files Browse the repository at this point in the history
…not be correctly parsed (apache#7343)
  • Loading branch information
lancelly authored Sep 16, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2f61131 commit 82cd039
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -2326,10 +2326,15 @@ private Long parseDateExpression(IoTDBSqlParser.DateExpressionContext ctx, long

private long parseTimeValue(IoTDBSqlParser.TimeValueContext ctx, long currentTime) {
if (ctx.INTEGER_LITERAL() != null) {
if (ctx.MINUS() != null) {
return -Long.parseLong(ctx.INTEGER_LITERAL().getText());
try {
if (ctx.MINUS() != null) {
return -Long.parseLong(ctx.INTEGER_LITERAL().getText());
}
return Long.parseLong(ctx.INTEGER_LITERAL().getText());
} catch (NumberFormatException e) {
throw new SQLParserException(
String.format("Can not parse %s to long value", ctx.INTEGER_LITERAL().getText()));
}
return Long.parseLong(ctx.INTEGER_LITERAL().getText());
} else if (ctx.dateExpression() != null) {
return parseDateExpression(ctx.dateExpression(), currentTime);
} else {
Original file line number Diff line number Diff line change
@@ -2795,10 +2795,15 @@ private Long parseDateExpression(IoTDBSqlParser.DateExpressionContext ctx, long

private long parseTimeValue(IoTDBSqlParser.TimeValueContext ctx, long currentTime) {
if (ctx.INTEGER_LITERAL() != null) {
if (ctx.MINUS() != null) {
return -Long.parseLong(ctx.INTEGER_LITERAL().getText());
try {
if (ctx.MINUS() != null) {
return -Long.parseLong(ctx.INTEGER_LITERAL().getText());
}
return Long.parseLong(ctx.INTEGER_LITERAL().getText());
} catch (NumberFormatException e) {
throw new SQLParserException(
String.format("Can not parse %s to long value", ctx.INTEGER_LITERAL().getText()));
}
return Long.parseLong(ctx.INTEGER_LITERAL().getText());
} else if (ctx.dateExpression() != null) {
return parseDateExpression(ctx.dateExpression(), currentTime);
} else {

0 comments on commit 82cd039

Please sign in to comment.