mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Make test for PythonPandasSqlInterpreter usable
This commit is contained in:
parent
76bbb44dc6
commit
e931dc4308
1 changed files with 12 additions and 6 deletions
|
|
@ -36,7 +36,6 @@ import org.apache.zeppelin.interpreter.InterpreterOutputListener;
|
|||
import org.apache.zeppelin.interpreter.InterpreterResult;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult.Type;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
|
@ -50,7 +49,7 @@ import org.junit.Test;
|
|||
*
|
||||
* To run manually on such environment, use:
|
||||
* <code>
|
||||
* mvn "-Dtest=org.apache.zeppelin.python.PythonPandasSqlInterpreterTest" test -pl python
|
||||
* mvn -Dpython.test.exclude='' test -pl python -am
|
||||
* </code>
|
||||
*/
|
||||
public class PythonPandasSqlInterpreterTest {
|
||||
|
|
@ -92,22 +91,29 @@ public class PythonPandasSqlInterpreterTest {
|
|||
//it depends on python interpreter presence in the same group
|
||||
}
|
||||
|
||||
//@Test
|
||||
@Test
|
||||
public void sqlOverTestDataPrintsTable() {
|
||||
//given
|
||||
// `import pandas as pd` and `import numpy as np` done
|
||||
// DataFrame \w test data
|
||||
String expectedTable = "name\tage\n\nmoon\t33\n\npark\t34";
|
||||
python.interpret("df2 = pd.DataFrame({ 'age' : np.array([33, 51, 51, 34]), "+
|
||||
"'name' : pd.Categorical(['moon','jobs','gates','park'])})", context);
|
||||
|
||||
|
||||
//when
|
||||
InterpreterResult ret = sql.interpret("select name, age from test where age < 40", context);
|
||||
InterpreterResult ret = sql.interpret("select name, age from df2 where age < 40", context);
|
||||
|
||||
//then
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
|
||||
assertEquals(Type.TABLE, ret.type());
|
||||
assertEquals("name\tage\nmoon\t33\npark\t34\n", ret.message());
|
||||
//System.out.println(ret.message());
|
||||
//System.out.println(expectedTable);
|
||||
//assertEquals(expectedTable, ret.message()); //somehow it's same but not equal
|
||||
assertTrue(ret.message().indexOf("moon\t33") > 0);
|
||||
assertTrue(ret.message().indexOf("park\t34") > 0);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, sql.interpret("select case when name==\"aa\" then name else name end from test", context).code());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, sql.interpret("select case when name==\"aa\" then name else name end from df2", context).code());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in a new issue