/** * Instantiates a new prepared query context. * * @param query the query * @param user the user * @param conf the conf */ public PreparedQueryContext(String query, String user, Configuration conf, Collection<LensDriver> drivers) { this(query, user, conf, new LensConf(), drivers); }
/** * Prepare query. * * @param sql the sql * @param queryName the query name * @return the query prepare handle * @throws LensAPIException */ @Deprecated public LensAPIResult<QueryPrepareHandle> prepareQuery(String sql, String queryName) throws LensAPIException { return prepareQuery(sql, queryName, new LensConf()); }
/** * Explain and prepare. * * @param sql the sql * @param queryName the query name * @return the query plan * @throws LensAPIException */ @Deprecated public LensAPIResult<QueryPlan> explainAndPrepare(String sql, String queryName) throws LensAPIException { return explainAndPrepare(sql, queryName, new LensConf()); }
/** * Prepare query. * * @param sql the sql * @param queryName the query name * @return the query prepare handle * @throws LensAPIException */ @Deprecated public LensAPIResult<QueryPrepareHandle> prepareQuery(String sql, String queryName) throws LensAPIException { return prepareQuery(sql, queryName, new LensConf()); }
/** * Explain query. * * @param sql the sql * @return the query plan * @throws LensAPIException */ @Deprecated public LensAPIResult<QueryPlan> explainQuery(String sql) throws LensAPIException { return explainQuery(sql, new LensConf()); }
@Deprecated public QueryHandle executePrepared(QueryPrepareHandle phandle, String queryName) { return executePrepared(phandle, queryName, new LensConf()); }
@Override public boolean execute(String s) throws SQLException { if (closed) { throw new SQLException("Cannot execute statemes on closed statements"); } try { statement.executeQuery(s, true, null, new LensConf()); } catch (Throwable t) { throw new SQLException(t); } return statement.wasQuerySuccessful(); }
@Override public boolean execute(String s) throws SQLException { if (closed) { throw new SQLException("Cannot execute statemes on closed statements"); } try { statement.executeQuery(s, true, null, new LensConf()); } catch (Throwable t) { throw new SQLException(t); } return statement.wasQuerySuccessful(); }
/** * To lens conf. * * @param conf the conf * @return the lens conf */ private LensConf toLensConf(HiveConf conf) { LensConf lensConf = new LensConf(); lensConf.getProperties().putAll(conf.getValByRegex(".*")); return lensConf; }
private void createDefaultUriProperties() { config = new LensConf(); config.addProperty(PATH_PREFIX + "hdfs", "://"); config.addProperty(PATH_PREFIX + "s3", "://"); config.addProperty(PATH_PREFIX + "s3n", "://"); }
public static Response postQuery(final WebTarget target, final Optional<LensSessionHandle> sessionId, final Optional<String> query, final Optional<String> operation, Optional<LensConf> lensConfOptional, MediaType mt) { FormDataMultiPart mp = FormDataMultiPartFactory .createFormDataMultiPartForQuery(sessionId, query, operation, lensConfOptional.or(new LensConf()), mt); return target.path("queryapi/queries").request(mt).post( Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE)); }
public static LensConf getLensConf(Object... args) { assert (args.length % 2 == 0); LensConf conf = new LensConf(); for (int i = 0; i < args.length; i += 2) { conf.addProperty(args[i], args[i + 1]); } return conf; } }
@Test(expectedExceptions = RuntimeException.class) public void testNonExistingFileShouldHadBeenDir() { /** Test: non existing file should had been dir **/ /* Should throw RuntimeException */ PathValidator validator = new PathValidator(new LensConf()); validator.getValidPath(NON_EXISTING_FILE, true, false); }
private void createDefaultUriProperties() { config = new LensConf(); config.addProperty(PATH_PREFIX + "hdfs", "://"); config.addProperty(PATH_PREFIX + "s3", "://"); config.addProperty(PATH_PREFIX + "s3n", "://"); }
@Test(expectedExceptions = RuntimeException.class) public void testDirShouldHadBeenFile() { /** Test: dir should had been file **/ if (!NON_EXISTING_FILE.exists()) { NON_EXISTING_FILE.mkdirs(); } /* Should throw RuntimeException */ PathValidator validator = new PathValidator(new LensConf()); validator.getValidPath(NON_EXISTING_FILE, false, false); }
@Override public ResultSet executeQuery(String s) throws SQLException { try { statement.executeQuery(s, true, null, new LensConf()); } catch (LensAPIException e) { log.error("Execution Failed for Statement:{}", s, e); } return new LensJdbcResultSet(statement.getResultSet(), statement.getResultSetMetaData(), this); }
@Override public ResultSet executeQuery(String s) throws SQLException { try { statement.executeQuery(s, true, null, new LensConf()); } catch (LensAPIException e) { log.error("Execution Failed for Statement:{}", s, e); } return new LensJdbcResultSet(statement.getResultSet(), statement.getResultSetMetaData(), this); }
private LensConf getLensConf(XJob job, SchedulerJobInstanceHandle instanceHandle, DateTime scheduledTime) { List<MapType> jobConf = job.getExecution().getQuery().getConf(); LensConf queryConf = new LensConf(); for (MapType element : jobConf) { queryConf.addProperty(element.getKey(), element.getValue()); } queryConf.addProperty(JOB_INSTANCE_ID_KEY, instanceHandle.getHandleId()); // Current time is used for resolving date. queryConf.addProperty(LensConfConstants.QUERY_CURRENT_TIME_IN_MILLIS, scheduledTime.getMillis()); return queryConf; }
@Test(dataProvider = "mediaTypeData") public void testErrorResponseWhenQueryIsAbsent(MediaType mt) { LensSessionHandle sessionId = openSession(target(), "foo", "bar", new LensConf(), mt); Optional<String> testQuery = Optional.absent(); Response response = estimate(target(), Optional.of(sessionId), testQuery, mt); final String expectedErrMsg = "Query is not provided, or it is empty or blank. Please provide a valid query."; LensErrorTO expectedLensErrorTO = LensErrorTO.composedOf( NULL_OR_EMPTY_OR_BLANK_QUERY.getLensErrorInfo().getErrorCode(), expectedErrMsg, MOCK_STACK_TRACE); ErrorResponseExpectedData expectedData = new ErrorResponseExpectedData(BAD_REQUEST, expectedLensErrorTO); expectedData.verify(response); closeSession(target(), sessionId, mt); }
private FormDataMultiPart getMultiFormData(String username, String password, MediaType mt) { final FormDataMultiPart mp = new FormDataMultiPart(); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), username)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), password)); mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(), new LensConf(), mt)); return mp; }