use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class BaseIndexInfo method buildSearchRow.
private void buildSearchRow(int i, Object match, Object value2, List<Object> toSearch) {
if (toSearch.size() != i) {
return;
}
if (value2 instanceof ArrayImpl && match instanceof int[]) {
int[] indexes = (int[]) match;
ArrayImpl array = (ArrayImpl) value2;
Object[] arrayVals = array.getValues();
for (int j = 0; j < indexes.length; j++) {
int index = indexes[j];
if (index == -1) {
break;
}
toSearch.add(arrayVals[index]);
}
} else {
toSearch.add(value2);
}
}
use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestArrayProcessing method testMultiDimensionalCast.
@Test
public void testMultiDimensionalCast() throws Exception {
// $NON-NLS-1$
String sql = "select cast( ((e2, e2), (e2, e2)) as object[]) from pm1.g1";
QueryResolver.resolveCommand(helpParse(sql), RealMetadataFactory.example1Cached());
Command command = helpResolve(sql, RealMetadataFactory.example1Cached());
assertEquals(Object[].class, command.getProjectedSymbols().get(0).getType());
ProcessorPlan pp = TestProcessor.helpGetPlan(command, RealMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.e2 FROM pm1.g1 AS g_0", Arrays.asList(1), Arrays.asList(2));
TestProcessor.helpProcess(pp, dataManager, new List[] { Arrays.asList(new ArrayImpl((Object[]) new Integer[][] { new Integer[] { 1, 1 }, new Integer[] { 1, 1 } })), Arrays.asList(new ArrayImpl((Object[]) new Integer[][] { new Integer[] { 2, 2 }, new Integer[] { 2, 2 } })) });
// $NON-NLS-1$
sql = "select cast(cast( ((e2, e2), (e2, e2)) as object[]) as integer[][]) from pm1.g1";
QueryResolver.resolveCommand(helpParse(sql), RealMetadataFactory.example1Cached());
command = helpResolve(sql, RealMetadataFactory.example1Cached());
assertEquals(Integer[][].class, command.getProjectedSymbols().get(0).getType());
}
use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestArrayProcessing method testNestedArrayAgg.
@Test
public void testNestedArrayAgg() throws Exception {
// $NON-NLS-1$
String sql = "select array_agg((e1, e2)) from pm1.g1";
Command command = helpParse(sql);
ProcessorPlan pp = TestProcessor.helpGetPlan(command, RealMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0", Arrays.asList("a", 1), Arrays.asList("c", 2));
TestProcessor.helpProcess(pp, dataManager, new List[] { Arrays.asList(new ArrayImpl(new Object[] { "a", 1 }, new Object[] { "c", 2 })) });
}
use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestProcedureProcessor method testVariadicParameterOrdering.
@Test
public void testVariadicParameterOrdering() throws Exception {
TransformationMetadata metadata = RealMetadataFactory.fromDDL("CREATE PROCEDURE p1(VARIADIC parameters integer) returns integer[] AS BEGIN " + "return parameters; END;", "x", "y");
StringBuilder sql = new StringBuilder("exec p1(0");
// dependent upon the jre. this is suffient to trigger the issue on oracle 1.8
int arraySize = 66000;
for (int i = 1; i < arraySize; i++) {
sql.append(',').append(i);
}
sql.append(')');
ProcessorPlan plan = helpGetPlan(sql.toString(), metadata);
CommandContext cc = TestProcessor.createCommandContext();
cc.setMetadata(metadata);
Integer[] val = new Integer[arraySize];
for (int i = 0; i < val.length; i++) {
val[i] = i;
}
ArrayImpl expected = new ArrayImpl(val);
HardcodedDataManager hdm = new HardcodedDataManager(metadata);
helpProcess(plan, cc, hdm, new List[] { Arrays.asList(expected) });
}
use of org.teiid.core.types.ArrayImpl in project teiid by teiid.
the class TestSQLXMLProcessing method testXmlTableSequenceArray.
@Test
public void testXmlTableSequenceArray() throws Exception {
// $NON-NLS-1$
String sql = "select * from xmltable('/a' passing convert('<a><b>first</b><b x=\"attr\">second</b></a>', xml) columns x string[] path 'b') as x";
List<?>[] expected = new List<?>[] { Arrays.asList(new ArrayImpl("first", "second")) };
process(sql, expected);
}
Aggregations