@Test public void testExractSampleRecordCountFromQuery() throws Exception { long res1 = postgresqlExtractor.exractSampleRecordCountFromQuery(QUERY_1); long res2 = postgresqlExtractor.exractSampleRecordCountFromQuery(QUERY_2); long res3 = postgresqlExtractor.exractSampleRecordCountFromQuery(QUERY_3); long res4 = postgresqlExtractor.exractSampleRecordCountFromQuery(QUERY_EMPTY); long res5 = postgresqlExtractor.exractSampleRecordCountFromQuery(QUERY_REG); assertEquals(res1, (long) 532); assertEquals(res2, (long) 50); assertEquals(res3, (long) 50); assertEquals(res4, (long) -1); assertEquals(res5, (long) -1); }
@Override public long exractSampleRecordCountFromQuery(String query) { if (StringUtils.isBlank(query)) { return SAMPLERECORDCOUNT; } long recordcount = SAMPLERECORDCOUNT; String limit = null; String inputQuery = query.toLowerCase(); int limitIndex = inputQuery.indexOf(" limit "); if (limitIndex > 0) { limit = query.substring(limitIndex + 7).trim(); } if (StringUtils.isNotBlank(limit)) { try { recordcount = Long.parseLong(limit); } catch (Exception e) { log.error("Ignoring incorrct limit value in input query:" + limit); } } return recordcount; }
PostgresqlExtractor extends JdbcExtractor { @Override public long exractSampleRecordCountFromQuery(String query) { if (StringUtils.isBlank(query)) { return SAMPLERECORDCOUNT; } long recordcount = SAMPLERECORDCOUNT; String limit = null; String inputQuery = query.toLowerCase(); int limitIndex = inputQuery.indexOf(" limit "); if (limitIndex > 0) { limit = query.substring(limitIndex + 7).trim(); } if (StringUtils.isNotBlank(limit)) { try { recordcount = Long.parseLong(limit); } catch (Exception e) { log.error("Ignoring incorrct limit value in input query:" + limit); } } return recordcount; } }
PostgresqlExtractor extends JdbcExtractor { @Override public long exractSampleRecordCountFromQuery(String query) { if (StringUtils.isBlank(query)) { return SAMPLERECORDCOUNT; } long recordcount = SAMPLERECORDCOUNT; String limit = null; String inputQuery = query.toLowerCase(); int limitIndex = inputQuery.indexOf(" limit "); if (limitIndex > 0) { limit = query.substring(limitIndex + 7).trim(); } if (StringUtils.isNotBlank(limit)) { try { recordcount = Long.parseLong(limit); } catch (Exception e) { log.error("Ignoring incorrct limit value in input query:" + limit); } } return recordcount; } PostgresqlExtractor(WorkUnitState workUnitState); }
PostgresqlExtractor extends JdbcExtractor { @Override public long exractSampleRecordCountFromQuery(String query) { if (StringUtils.isBlank(query)) { return SAMPLERECORDCOUNT; } long recordcount = SAMPLERECORDCOUNT; String limit = null; String inputQuery = query.toLowerCase(); int limitIndex = inputQuery.indexOf(" limit "); if (limitIndex > 0) { limit = query.substring(limitIndex + 7).trim(); } if (StringUtils.isNotBlank(limit)) { try { recordcount = Long.parseLong(limit); } catch (Exception e) { log.error("Ignoring incorrct limit value in input query:" + limit); } } return recordcount; } PostgresqlExtractor(WorkUnitState workUnitState); @Override String getHourPredicateCondition(String column, long value, String valueFormat, String operator); @Override String getDatePredicateCondition(String column, long value, String valueFormat, String operator); @Override String getTimestampPredicateCondition(String column, long value, String valueFormat, String operator); @Override List<Command> getSchemaMetadata(String schema, String entity); @Override List<Command> getHighWatermarkMetadata(String schema, String entity, String watermarkColumn,
      List<Predicate> predicateList); @Override List<Command> getCountMetadata(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList); @Override List<Command> getDataMetadata(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList); @Override String getConnectionUrl(); @Override Map<String, String> getDataTypeMap(); @Override String getWatermarkSourceFormat(WatermarkType watermarkType); @Override long exractSampleRecordCountFromQuery(String query); @Override String removeSampleClauseFromQuery(String query); @Override String constructSampleClause(); @Override String getLeftDelimitedIdentifier(); @Override String getRightDelimitedIdentifier(); @Override Iterator<JsonElement> getRecordSetFromSourceApi(String schema, String entity, WorkUnit workUnit,
      List<Predicate> predicateList); }
PostgresqlExtractor extends JdbcExtractor { @Override public long exractSampleRecordCountFromQuery(String query) { if (StringUtils.isBlank(query)) { return SAMPLERECORDCOUNT; } long recordcount = SAMPLERECORDCOUNT; String limit = null; String inputQuery = query.toLowerCase(); int limitIndex = inputQuery.indexOf(" limit "); if (limitIndex > 0) { limit = query.substring(limitIndex + 7).trim(); } if (StringUtils.isNotBlank(limit)) { try { recordcount = Long.parseLong(limit); } catch (Exception e) { log.error("Ignoring incorrct limit value in input query:" + limit); } } return recordcount; } PostgresqlExtractor(WorkUnitState workUnitState); @Override String getHourPredicateCondition(String column, long value, String valueFormat, String operator); @Override String getDatePredicateCondition(String column, long value, String valueFormat, String operator); @Override String getTimestampPredicateCondition(String column, long value, String valueFormat, String operator); @Override List<Command> getSchemaMetadata(String schema, String entity); @Override List<Command> getHighWatermarkMetadata(String schema, String entity, String watermarkColumn,
      List<Predicate> predicateList); @Override List<Command> getCountMetadata(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList); @Override List<Command> getDataMetadata(String schema, String entity, WorkUnit workUnit, List<Predicate> predicateList); @Override String getConnectionUrl(); @Override Map<String, String> getDataTypeMap(); @Override String getWatermarkSourceFormat(WatermarkType watermarkType); @Override long exractSampleRecordCountFromQuery(String query); @Override String removeSampleClauseFromQuery(String query); @Override String constructSampleClause(); @Override String getLeftDelimitedIdentifier(); @Override String getRightDelimitedIdentifier(); @Override Iterator<JsonElement> getRecordSetFromSourceApi(String schema, String entity, WorkUnit workUnit,
      List<Predicate> predicateList);  }