Skip to content

Commit

Permalink
add testcase & bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jun 25, 2022
1 parent 5b7fbbc commit fdeac25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public JSONExtractInt32(String path) {

public IntWritable eval(Text input) {
JSONReader parser = JSONReader.of(input.getBytes(), 0, input.getLength(), StandardCharsets.UTF_8);
int value = path.extractInt32(parser);
int value = path.extractInt32Value(parser);
if (parser.wasNull()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.alibaba.fastjson2.odps;

import com.alibaba.fastjson2.support.odps.JSONExtract2;
import com.alibaba.fastjson2.support.odps.JSONExtractInt32;
import com.alibaba.fastjson2.support.odps.JSONExtractInt64;
import com.aliyun.odps.io.Text;
import org.junit.jupiter.api.Test;
Expand All @@ -19,6 +20,14 @@ public void test() {

@Test
public void test2() {
JSONExtractInt32 udf = new JSONExtractInt32("$");
assertNull(udf.eval(new Text("null")));
assertNotNull(udf.eval(new Text("123")));
assertEquals("123", udf.eval(new Text("123")).toString());
}

@Test
public void test23() {
JSONExtractInt64 udf = new JSONExtractInt64("$");
assertNull(udf.eval(new Text("null")));
assertNotNull(udf.eval(new Text("123")));
Expand Down

0 comments on commit fdeac25

Please sign in to comment.