Java Code Examples for com.klarna.hiverunner.HiveShell#start()
The following examples show how to use
com.klarna.hiverunner.HiveShell#start() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 6 votes |
@Test public void executeQueryFromFile() throws IOException { HiveShell shell = createHiveCliShell(); shell.start(); String statement = "select current_database(), NULL, 100"; when(container.executeStatement(statement)).thenReturn(Arrays.<Object[]> asList( new Object[] {"default", null, 100})); String hiveSql = statement + ";"; File file = tempFolder.newFile("script.sql"); Files.write(hiveSql, file, UTF_8); List<String> results = shell.executeQuery(UTF_8, Paths.get(file.toURI()), "xxx", "yyy"); assertThat(results.size(), is(1)); assertThat(results.get(0), is("defaultxxxyyyxxx100")); }
Example 2
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 6 votes |
@Test public void scriptFilesAreImportedInQueries() throws IOException { String hiveSql = "use default"; File importedFile = new File(tempFolder.getRoot(), "imported_script.sql"); Files.write(hiveSql, importedFile, UTF_8); HiveShell shell = createHiveCliShell(); shell.start(); String importhiveSql = "source " + importedFile.getAbsolutePath(); List<String> results = shell.executeQuery(importhiveSql); assertThat(results.size(), is(0)); verify(container).executeStatement(hiveSql); }
Example 3
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 6 votes |
@Test public void scriptFilesAreImportedInOtherScriptsHiveCli() throws IOException { String hiveSql = "use default"; File importedFile = new File(tempFolder.getRoot(), "imported_script.sql"); Files.write(hiveSql, importedFile, UTF_8); HiveShell shell = createHiveCliShell(); shell.start(); String importhiveSql = "source " + importedFile.getAbsolutePath(); File file = new File(tempFolder.getRoot(), "script.sql"); Files.write(importhiveSql, file, UTF_8); shell.execute(file); verify(container).executeStatement(hiveSql); }
Example 4
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 6 votes |
@Test public void scriptFilesAreImportedInOtherScriptsBeeline() throws IOException { String hiveSql = "use default"; File importedFile = new File(tempFolder.getRoot(), "imported_script.sql"); Files.write(hiveSql, importedFile, UTF_8); HiveShell shell = createBeelineShell(); shell.start(); String importhiveSql = "!run " + importedFile.getAbsolutePath(); File file = new File(tempFolder.getRoot(), "script.sql"); Files.write(importhiveSql, file, UTF_8); shell.execute(file); verify(container).executeStatement(hiveSql); }
Example 5
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 5 votes |
@Test public void setupScriptsShouldBeExecutedAtStart() throws IOException { HiveShell shell = createHiveCliShell(); shell.addSetupScript("foo"); shell.addSetupScripts(tempFolder.newFile("foo")); shell.start(); }
Example 6
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 5 votes |
@Test public void executeScriptFile() throws IOException { String hiveSql = "use default"; File file = new File(tempFolder.getRoot(), "script.sql"); Files.write(hiveSql, file, UTF_8); HiveShell shell = createHiveCliShell(); shell.start(); shell.execute(file); verify(container).executeStatement(hiveSql); }
Example 7
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 5 votes |
@Test public void executeScriptCharsetFile() throws IOException { String hiveSql = "use default"; File file = new File(tempFolder.getRoot(), "script.sql"); Files.write(hiveSql, file, UTF_8); HiveShell shell = createHiveCliShell(); shell.start(); shell.execute(UTF_8, file); verify(container).executeStatement(hiveSql); }
Example 8
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 5 votes |
@Test public void executeScriptPath() throws IOException { String hiveSql = "use default"; File file = new File(tempFolder.getRoot(), "script.sql"); Files.write(hiveSql, file, UTF_8); HiveShell shell = createHiveCliShell(); shell.start(); shell.execute(Paths.get(file.toURI())); verify(container).executeStatement(hiveSql); }
Example 9
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 5 votes |
@Test public void executeScriptCharsetPath() throws IOException { String hiveSql = "use default"; File file = new File(tempFolder.getRoot(), "script.sql"); Files.write(hiveSql, file, UTF_8); HiveShell shell = createHiveCliShell(); shell.start(); shell.execute(UTF_8, Paths.get(file.toURI())); verify(container).executeStatement(hiveSql); }
Example 10
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void executeScriptFileNotExists() throws IOException { File file = new File(tempFolder.getRoot(), "script.sql"); HiveShell shell = createHiveCliShell(); shell.start(); shell.execute(UTF_8, Paths.get(file.toURI())); }
Example 11
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void executeQueryFromFileMoreThanOneStatement() throws IOException { HiveShell shell = createHiveCliShell(); shell.start(); String hiveSql = "use default;\nselect current_database(), NULL, 100;"; File file = new File(tempFolder.getRoot(), "script.sql"); Files.write(hiveSql, file, UTF_8); shell.executeQuery(UTF_8, Paths.get(file.toURI()), "xxx", "yyy"); }
Example 12
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void executeQueryFromFileZeroStatements() throws IOException { HiveShell shell = createHiveCliShell(); shell.start(); String hiveSql = ""; File file = new File(tempFolder.getRoot(), "script.sql"); Files.write(hiveSql, file, UTF_8); shell.executeQuery(UTF_8, Paths.get(file.toURI()), "xxx", "yyy"); }
Example 13
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 4 votes |
@Test(expected = IllegalStateException.class) public void setupScriptMayNotBeAddedAfterShellIsStarted() { HiveShell shell = createHiveCliShell(); shell.start(); shell.addSetupScript("foo"); }
Example 14
Source File: HiveShellBaseTest.java From HiveRunner with Apache License 2.0 | 4 votes |
@Test(expected = IllegalStateException.class) public void setupScriptsMayNotBeAddedAfterShellIsStarted() throws IOException { HiveShell shell = createHiveCliShell(); shell.start(); shell.addSetupScripts(tempFolder.newFile("foo")); }