Java Code Examples for org.apache.hadoop.hive.ql.io.sarg.SearchArgument#getLeaves()

The following examples show how to use org.apache.hadoop.hive.ql.io.sarg.SearchArgument#getLeaves() . 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: OrcRowInputFormatTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimePredicates() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_TIMETYPES), TEST_SCHEMA_TIMETYPES, new Configuration());

	rowOrcInputFormat.addPredicate(
		// OR
		new OrcRowInputFormat.Or(
			// timestamp pred
			new OrcRowInputFormat.Equals("time", PredicateLeaf.Type.TIMESTAMP, Timestamp.valueOf("1900-05-05 12:34:56.100")),
			// date pred
			new OrcRowInputFormat.Equals("date", PredicateLeaf.Type.DATE, Date.valueOf("1900-12-25")))
		);

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);
	Reader.Options options = new Reader.Options();
	doReturn(options).when(spy).getOptions(any());

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = options.getSearchArgument();
	assertNotNull(sarg);
	assertEquals("(or leaf-0 leaf-1)", sarg.getExpression().toString());
	assertEquals(2, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS time 1900-05-05 12:34:56.1)", leaves.get(0).toString());
	assertEquals("(EQUALS date 1900-12-25)", leaves.get(1).toString());
}
 
Example 2
Source File: OrcRowInputFormatTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Test
public void testDecimalPredicate() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_DECIMAL), TEST_SCHEMA_DECIMAL, new Configuration());

	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Not(
			// decimal pred
			new OrcRowInputFormat.Equals("_col0", PredicateLeaf.Type.DECIMAL, BigDecimal.valueOf(-1000.5))));

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);
	Reader.Options options = new Reader.Options();
	doReturn(options).when(spy).getOptions(any());

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = options.getSearchArgument();
	assertNotNull(sarg);
	assertEquals("(not leaf-0)", sarg.getExpression().toString());
	assertEquals(1, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS _col0 -1000.5)", leaves.get(0).toString());
}
 
Example 3
Source File: OrcRowInputFormatTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimePredicates() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_TIMETYPES), TEST_SCHEMA_TIMETYPES, new Configuration());

	rowOrcInputFormat.addPredicate(
		// OR
		new OrcRowInputFormat.Or(
			// timestamp pred
			new OrcRowInputFormat.Equals("time", PredicateLeaf.Type.TIMESTAMP, Timestamp.valueOf("1900-05-05 12:34:56.100")),
			// date pred
			new OrcRowInputFormat.Equals("date", PredicateLeaf.Type.DATE, Date.valueOf("1900-12-25")))
		);

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);
	Reader.Options options = new Reader.Options();
	doReturn(options).when(spy).getOptions(any());

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = options.getSearchArgument();
	assertNotNull(sarg);
	assertEquals("(or leaf-0 leaf-1)", sarg.getExpression().toString());
	assertEquals(2, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS time 1900-05-05 12:34:56.1)", leaves.get(0).toString());
	assertEquals("(EQUALS date 1900-12-25)", leaves.get(1).toString());
}
 
Example 4
Source File: OrcRowInputFormatTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDecimalPredicate() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_DECIMAL), TEST_SCHEMA_DECIMAL, new Configuration());

	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Not(
			// decimal pred
			new OrcRowInputFormat.Equals("_col0", PredicateLeaf.Type.DECIMAL, BigDecimal.valueOf(-1000.5))));

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);
	Reader.Options options = new Reader.Options();
	doReturn(options).when(spy).getOptions(any());

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = options.getSearchArgument();
	assertNotNull(sarg);
	assertEquals("(not leaf-0)", sarg.getExpression().toString());
	assertEquals(1, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS _col0 -1000.5)", leaves.get(0).toString());
}
 
Example 5
Source File: OrcRowInputFormatTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testTimePredicates() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_TIMETYPES), TEST_SCHEMA_TIMETYPES, new Configuration());

	rowOrcInputFormat.addPredicate(
		// OR
		new OrcSplitReader.Or(
			// timestamp pred
			new OrcSplitReader.Equals("time", PredicateLeaf.Type.TIMESTAMP, Timestamp.valueOf("1900-05-05 12:34:56.100")),
			// date pred
			new OrcSplitReader.Equals("date", PredicateLeaf.Type.DATE, Date.valueOf("1900-12-25")))
		);

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = getSearchArgument(spy.getReader().getRecordReader());
	assertNotNull(sarg);
	assertEquals("(or leaf-0 leaf-1)", sarg.getExpression().toString());
	assertEquals(2, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS time 1900-05-05 12:34:56.1)", leaves.get(0).toString());
	assertEquals("(EQUALS date 1900-12-25)", leaves.get(1).toString());
}
 
Example 6
Source File: OrcRowInputFormatTest.java    From flink with Apache License 2.0 5 votes vote down vote up
@Test
public void testDecimalPredicate() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_DECIMAL), TEST_SCHEMA_DECIMAL, new Configuration());

	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.Not(
			// decimal pred
			new OrcSplitReader.Equals("_col0", PredicateLeaf.Type.DECIMAL, BigDecimal.valueOf(-1000.5))));

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = getSearchArgument(spy.getReader().getRecordReader());
	assertNotNull(sarg);
	assertEquals("(not leaf-0)", sarg.getExpression().toString());
	assertEquals(1, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS _col0 -1000.5)", leaves.get(0).toString());
}
 
Example 7
Source File: OrcRowInputFormatTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Test
public void testNumericBooleanStringPredicates() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_NESTED), TEST_SCHEMA_NESTED, new Configuration());

	rowOrcInputFormat.selectFields(0, 1, 2, 3, 4, 5, 6, 8);

	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("boolean1", PredicateLeaf.Type.BOOLEAN, false));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.LessThan("byte1", PredicateLeaf.Type.LONG, 1));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.LessThanEquals("short1", PredicateLeaf.Type.LONG, 1024));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Between("int1", PredicateLeaf.Type.LONG, -1, 65536));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("long1", PredicateLeaf.Type.LONG, 9223372036854775807L));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("float1", PredicateLeaf.Type.FLOAT, 1.0));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("double1", PredicateLeaf.Type.FLOAT, -15.0));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.IsNull("string1", PredicateLeaf.Type.STRING));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("string1", PredicateLeaf.Type.STRING, "hello"));

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);
	Reader.Options options = new Reader.Options();
	doReturn(options).when(spy).getOptions(any());

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = options.getSearchArgument();
	assertNotNull(sarg);
	assertEquals("(and leaf-0 leaf-1 leaf-2 leaf-3 leaf-4 leaf-5 leaf-6 leaf-7 leaf-8)", sarg.getExpression().toString());
	assertEquals(9, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS boolean1 false)", leaves.get(0).toString());
	assertEquals("(LESS_THAN byte1 1)", leaves.get(1).toString());
	assertEquals("(LESS_THAN_EQUALS short1 1024)", leaves.get(2).toString());
	assertEquals("(BETWEEN int1 -1 65536)", leaves.get(3).toString());
	assertEquals("(EQUALS long1 9223372036854775807)", leaves.get(4).toString());
	assertEquals("(EQUALS float1 1.0)", leaves.get(5).toString());
	assertEquals("(EQUALS double1 -15.0)", leaves.get(6).toString());
	assertEquals("(IS_NULL string1)", leaves.get(7).toString());
	assertEquals("(EQUALS string1 hello)", leaves.get(8).toString());
}
 
Example 8
Source File: OrcRowInputFormatTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testNumericBooleanStringPredicates() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_NESTED), TEST_SCHEMA_NESTED, new Configuration());

	rowOrcInputFormat.selectFields(0, 1, 2, 3, 4, 5, 6, 8);

	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("boolean1", PredicateLeaf.Type.BOOLEAN, false));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.LessThan("byte1", PredicateLeaf.Type.LONG, 1));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.LessThanEquals("short1", PredicateLeaf.Type.LONG, 1024));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Between("int1", PredicateLeaf.Type.LONG, -1, 65536));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("long1", PredicateLeaf.Type.LONG, 9223372036854775807L));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("float1", PredicateLeaf.Type.FLOAT, 1.0));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("double1", PredicateLeaf.Type.FLOAT, -15.0));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.IsNull("string1", PredicateLeaf.Type.STRING));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcRowInputFormat.Equals("string1", PredicateLeaf.Type.STRING, "hello"));

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);
	Reader.Options options = new Reader.Options();
	doReturn(options).when(spy).getOptions(any());

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = options.getSearchArgument();
	assertNotNull(sarg);
	assertEquals("(and leaf-0 leaf-1 leaf-2 leaf-3 leaf-4 leaf-5 leaf-6 leaf-7 leaf-8)", sarg.getExpression().toString());
	assertEquals(9, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS boolean1 false)", leaves.get(0).toString());
	assertEquals("(LESS_THAN byte1 1)", leaves.get(1).toString());
	assertEquals("(LESS_THAN_EQUALS short1 1024)", leaves.get(2).toString());
	assertEquals("(BETWEEN int1 -1 65536)", leaves.get(3).toString());
	assertEquals("(EQUALS long1 9223372036854775807)", leaves.get(4).toString());
	assertEquals("(EQUALS float1 1.0)", leaves.get(5).toString());
	assertEquals("(EQUALS double1 -15.0)", leaves.get(6).toString());
	assertEquals("(IS_NULL string1)", leaves.get(7).toString());
	assertEquals("(EQUALS string1 hello)", leaves.get(8).toString());
}
 
Example 9
Source File: OrcRowInputFormatTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Test
public void testNumericBooleanStringPredicates() throws Exception {
	rowOrcInputFormat =
		new OrcRowInputFormat(getPath(TEST_FILE_NESTED), TEST_SCHEMA_NESTED, new Configuration());

	rowOrcInputFormat.selectFields(0, 1, 2, 3, 4, 5, 6, 8);

	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.Equals("boolean1", PredicateLeaf.Type.BOOLEAN, false));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.LessThan("byte1", PredicateLeaf.Type.LONG, 1));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.LessThanEquals("short1", PredicateLeaf.Type.LONG, 1024));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.Between("int1", PredicateLeaf.Type.LONG, -1, 65536));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.Equals("long1", PredicateLeaf.Type.LONG, 9223372036854775807L));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.Equals("float1", PredicateLeaf.Type.FLOAT, 1.0));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.Equals("double1", PredicateLeaf.Type.FLOAT, -15.0));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.IsNull("string1", PredicateLeaf.Type.STRING));
	// boolean pred
	rowOrcInputFormat.addPredicate(
		new OrcSplitReader.Equals("string1", PredicateLeaf.Type.STRING, "hello"));

	FileInputSplit[] splits = rowOrcInputFormat.createInputSplits(1);
	rowOrcInputFormat.openInputFormat();

	// mock options to check configuration of ORC reader
	OrcRowInputFormat spy = spy(rowOrcInputFormat);

	spy.openInputFormat();
	spy.open(splits[0]);

	// verify predicate configuration
	SearchArgument sarg = getSearchArgument(spy.getReader().getRecordReader());
	assertNotNull(sarg);
	assertEquals("(and leaf-0 leaf-1 leaf-2 leaf-3 leaf-4 leaf-5 leaf-6 leaf-7 leaf-8)", sarg.getExpression().toString());
	assertEquals(9, sarg.getLeaves().size());
	List<PredicateLeaf> leaves = sarg.getLeaves();
	assertEquals("(EQUALS boolean1 false)", leaves.get(0).toString());
	assertEquals("(LESS_THAN byte1 1)", leaves.get(1).toString());
	assertEquals("(LESS_THAN_EQUALS short1 1024)", leaves.get(2).toString());
	assertEquals("(BETWEEN int1 -1 65536)", leaves.get(3).toString());
	assertEquals("(EQUALS long1 9223372036854775807)", leaves.get(4).toString());
	assertEquals("(EQUALS float1 1.0)", leaves.get(5).toString());
	assertEquals("(EQUALS double1 -15.0)", leaves.get(6).toString());
	assertEquals("(IS_NULL string1)", leaves.get(7).toString());
	assertEquals("(EQUALS string1 hello)", leaves.get(8).toString());
}