use of herddb.mem.MemoryMetadataStorageManager in project herddb by diennea.
the class SimpleJoinTest method testStartTransactionInJoinBranch.
@Test
public void testStartTransactionInJoinBranch() throws Exception {
String nodeId = "localhost";
try (DBManager manager = new DBManager("localhost", new MemoryMetadataStorageManager(), new MemoryDataStorageManager(), new MemoryCommitLogManager(), null, null)) {
manager.start();
CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.waitForTablespace("tblspace1", 10000);
execute(manager, "CREATE TABLE tblspace1.table1 (k1 string primary key,n1 int,s1 string)", Collections.emptyList());
execute(manager, "CREATE TABLE tblspace1.table2 (k2 string primary key,n2 int,s2 string)", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.table1 (k1,n1,s1) values('a',1,'A')", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.table1 (k1,n1,s1) values('b',2,'B')", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.table2 (k2,n2,s2) values('c',3,'A')", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.table2 (k2,n2,s2) values('d',4,'A')", Collections.emptyList());
{
TranslatedQuery translated = manager.getPlanner().translate(TableSpace.DEFAULT, "SELECT * FROM" + " tblspace1.table1 t1" + " JOIN tblspace1.table2 t2" + " ON t1.n1 > 0" + " and t2.n2 >= 1", Collections.emptyList(), true, true, false, -1);
translated.context.setForceRetainReadLock(true);
if (manager.getPlanner() instanceof CalcitePlanner) {
assertThat(translated.plan.originalRoot, instanceOf(NestedLoopJoinOp.class));
NestedLoopJoinOp join = (NestedLoopJoinOp) translated.plan.originalRoot;
assertThat(join.getLeft(), instanceOf(SimpleScanOp.class));
assertThat(join.getRight(), instanceOf(SimpleScanOp.class));
}
// we want that the left branch of the join starts the transactoion
ScanResult scanResult = ((ScanResult) manager.executePlan(translated.plan, translated.context, TransactionContext.AUTOTRANSACTION_TRANSACTION));
List<DataAccessor> tuples = scanResult.dataScanner.consumeAndClose();
assertTrue(scanResult.transactionId > 0);
for (DataAccessor t : tuples) {
System.out.println("t:" + t);
assertEquals(6, t.getFieldNames().length);
assertEquals("k1", t.getFieldNames()[0]);
assertEquals("n1", t.getFieldNames()[1]);
assertEquals("s1", t.getFieldNames()[2]);
assertEquals("k2", t.getFieldNames()[3]);
assertEquals("n2", t.getFieldNames()[4]);
assertEquals("s2", t.getFieldNames()[5]);
}
assertEquals(4, tuples.size());
TestUtils.commitTransaction(manager, "tblspace1", scanResult.transactionId);
}
{
TranslatedQuery translated = manager.getPlanner().translate(TableSpace.DEFAULT, "SELECT * FROM" + " tblspace1.table1 t1" + " JOIN tblspace1.table2 t2" + " ON t1.n1 > 0" + " and t2.n2 >= 1" + " order by t1.n1, t2.n2", Collections.emptyList(), true, true, false, // with order by
-1);
translated.context.setForceRetainReadLock(true);
assertThat(translated.plan.originalRoot, instanceOf(SortOp.class));
if (manager.getPlanner() instanceof CalcitePlanner) {
NestedLoopJoinOp join = (NestedLoopJoinOp) ((SortOp) translated.plan.originalRoot).getInput();
assertThat(join.getLeft(), instanceOf(SimpleScanOp.class));
assertThat(join.getRight(), instanceOf(SimpleScanOp.class));
} else {
JoinOp join = (JoinOp) ((SortOp) translated.plan.originalRoot).getInput();
assertThat(join.getLeft(), instanceOf(SimpleScanOp.class));
assertThat(join.getRight(), instanceOf(SimpleScanOp.class));
}
// we want that the left branch of the join starts the transactoion
ScanResult scanResult = ((ScanResult) manager.executePlan(translated.plan, translated.context, TransactionContext.AUTOTRANSACTION_TRANSACTION));
List<DataAccessor> tuples = scanResult.dataScanner.consumeAndClose();
assertTrue(scanResult.transactionId > 0);
for (DataAccessor t : tuples) {
System.out.println("t:" + t);
assertEquals(6, t.getFieldNames().length);
assertEquals("k1", t.getFieldNames()[0]);
assertEquals("n1", t.getFieldNames()[1]);
assertEquals("s1", t.getFieldNames()[2]);
assertEquals("k2", t.getFieldNames()[3]);
assertEquals("n2", t.getFieldNames()[4]);
assertEquals("s2", t.getFieldNames()[5]);
}
assertEquals(4, tuples.size());
TestUtils.commitTransaction(manager, "tblspace1", scanResult.transactionId);
}
{
TranslatedQuery translated = manager.getPlanner().translate(TableSpace.DEFAULT, "SELECT t1.s1 FROM" + " tblspace1.table1 t1" + " JOIN tblspace1.table2 t2" + " ON t1.n1 > 0" + " and t2.n2 >= 1" + " order by t1.n1, t2.n2", Collections.emptyList(), true, true, false, // with order by on non selected fields
-1);
translated.context.setForceRetainReadLock(true);
assertThat(translated.plan.originalRoot, instanceOf(ProjectOp.class));
SortOp sort = (SortOp) ((ProjectOp) translated.plan.originalRoot).getInput();
assertThat(((ProjectOp) translated.plan.originalRoot).getProjection(), instanceOf(ProjectOp.ZeroCopyProjection.class));
if (manager.getPlanner() instanceof CalcitePlanner) {
NestedLoopJoinOp join = (NestedLoopJoinOp) sort.getInput();
assertThat(join.getLeft(), instanceOf(SimpleScanOp.class));
assertThat(join.getRight(), instanceOf(SimpleScanOp.class));
} else {
JoinOp join = (JoinOp) sort.getInput();
assertThat(join.getLeft(), instanceOf(SimpleScanOp.class));
assertThat(join.getRight(), instanceOf(SimpleScanOp.class));
}
// we want that the left branch of the join starts the transactoion
ScanResult scanResult = ((ScanResult) manager.executePlan(translated.plan, translated.context, TransactionContext.AUTOTRANSACTION_TRANSACTION));
List<DataAccessor> tuples = scanResult.dataScanner.consumeAndClose();
assertTrue(scanResult.transactionId > 0);
for (DataAccessor t : tuples) {
System.out.println("t:" + t);
assertEquals(1, t.getFieldNames().length);
assertEquals("s1", t.getFieldNames()[0]);
}
assertEquals(4, tuples.size());
TestUtils.commitTransaction(manager, "tblspace1", scanResult.transactionId);
}
}
}
use of herddb.mem.MemoryMetadataStorageManager in project herddb by diennea.
the class SimpleJoinTest method testSubQueryInSelect.
@Test
public void testSubQueryInSelect() throws Exception {
String nodeId = "localhost";
try (DBManager manager = new DBManager("localhost", new MemoryMetadataStorageManager(), new MemoryDataStorageManager(), new MemoryCommitLogManager(), null, null)) {
assumeThat(manager.getPlanner(), instanceOf(CalcitePlanner.class));
manager.start();
CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.waitForTablespace("tblspace1", 10000);
execute(manager, "CREATE TABLE tblspace1.table1 (k1 string primary key,n1 int,s1 string)", Collections.emptyList());
execute(manager, "CREATE TABLE tblspace1.table2 (k2 string primary key,n2 int,s2 string)", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.table1 (k1,n1,s1) values('a',1,'A')", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.table1 (k1,n1,s1) values('b',2,'B')", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.table2 (k2,n2,s2) values('c',3,'A')", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.table2 (k2,n2,s2) values('d',4,'A')", Collections.emptyList());
{
List<DataAccessor> tuples = scan(manager, "SELECT t1.k1, max(n1) as maxn1, max(select n2 from tblspace1.table2 t2 WHERE t1.s1=t2.s2) as maxn2 FROM " + " tblspace1.table1 t1 " + " group by k1", Collections.emptyList()).consumeAndClose();
for (DataAccessor t : tuples) {
System.out.println("t:" + t);
assertEquals(3, t.getFieldNames().length);
assertEquals("k1", t.getFieldNames()[0]);
assertEquals("maxn1", t.getFieldNames()[1]);
assertEquals("maxn2", t.getFieldNames()[2]);
}
assertEquals(2, tuples.size());
assertTrue(tuples.stream().anyMatch(t -> t.toMap().equals(MapUtils.map("k1", RawString.of("a"), "maxn1", 1, "maxn2", 4))));
assertTrue(tuples.stream().anyMatch(t -> t.toMap().equals(MapUtils.map("k1", RawString.of("b"), "maxn1", 2, "maxn2", null))));
}
{
List<DataAccessor> tuples = scan(manager, "SELECT t1.k1, max(n1) as maxn1, max(select n2 from tblspace1.table2 t2 WHERE t1.s1=t2.s2) as maxn2 FROM " + " tblspace1.table1 t1 " + " group by k1" + " order by max(select n2 from tblspace1.table2 t2 WHERE t1.s1=t2.s2) desc", Collections.emptyList()).consumeAndClose();
for (DataAccessor t : tuples) {
System.out.println("t:" + t);
assertEquals(3, t.getFieldNames().length);
assertEquals("k1", t.getFieldNames()[0]);
assertEquals("maxn1", t.getFieldNames()[1]);
assertEquals("maxn2", t.getFieldNames()[2]);
}
assertEquals(2, tuples.size());
assertTrue(tuples.get(0).toMap().equals(MapUtils.map("k1", RawString.of("b"), "maxn1", 2, "maxn2", null)));
assertTrue(tuples.get(1).toMap().equals(MapUtils.map("k1", RawString.of("a"), "maxn1", 1, "maxn2", 4)));
}
execute(manager, "INSERT INTO tblspace1.table2 (k2,n2,s2) values('a',1,'A')", Collections.emptyList());
{
List<DataAccessor> tuples = scan(manager, "SELECT * FROM tblspace1.table1 t1, tblspace1.table2 t2 WHERE t1.k1=? and t2.k2=? and t1.k1=t2.k2", Arrays.asList("a", "a")).consumeAndClose();
for (DataAccessor t : tuples) {
System.out.println("t:" + t);
assertEquals(6, t.getFieldNames().length);
}
assertEquals(1, tuples.size());
}
}
}
use of herddb.mem.MemoryMetadataStorageManager in project herddb by diennea.
the class CalcitePlannerTest method showCreateTable_Within_TransactionContext.
@Test(expected = TableDoesNotExistException.class)
public void showCreateTable_Within_TransactionContext() throws Exception {
String nodeId = "localhost";
try (DBManager manager = new DBManager("localhost", new MemoryMetadataStorageManager(), new MemoryDataStorageManager(), new MemoryCommitLogManager(), null, null)) {
manager.start();
CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.waitForTablespace("tblspace1", 10000);
long tx = beginTransaction(manager, "tblspace1");
execute(manager, "CREATE TABLE tblspace1.test (k1 string primary key," + "s1 string not null)", Collections.emptyList(), new TransactionContext(tx));
TranslatedQuery translatedQuery = manager.getPlanner().translate("herd", "SHOW CREATE TABLE tblspace1.test", Collections.emptyList(), true, false, true, -1);
}
}
use of herddb.mem.MemoryMetadataStorageManager in project herddb by diennea.
the class CalcitePlannerTest method simplePlansTests.
@Test
public void simplePlansTests() throws Exception {
String nodeId = "localhost";
try (DBManager manager = new DBManager("localhost", new MemoryMetadataStorageManager(), new MemoryDataStorageManager(), new MemoryCommitLogManager(), null, null)) {
manager.start();
CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.waitForTablespace("tblspace1", 10000);
execute(manager, "CREATE TABLE tblspace1.tsql (k1 string primary key,n1 int,s1 string)", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.tsql (k1,n1) values(?,?)", Arrays.asList("mykey", 1234), TransactionContext.NO_TRANSACTION);
try (DataScanner scan = scan(manager, "SELECT * FROM tblspace1.tsql", Collections.emptyList())) {
assertEquals(1, scan.consume().size());
}
try (DataScanner scan = scan(manager, "SELECT n1,k1 FROM tblspace1.tsql", Collections.emptyList())) {
assertEquals(1, scan.consume().size());
}
try (DataScanner scan = scan(manager, "SELECT k1,n1 FROM tblspace1.tsql", Collections.emptyList())) {
assertEquals(1, scan.consume().size());
}
try (DataScanner scan = scan(manager, "SELECT n1,k1 FROM tblspace1.tsql where k1='mykey'", Collections.emptyList())) {
assertEquals(1, scan.consume().size());
}
{
// test ReduceExpressionsRule.FILTER_INSTANCE
// "n1 = 1 and n1 is not null" -> this must be simplified to "n1 = 1"
BindableTableScanOp plan = assertInstanceOf(plan(manager, "select * from tblspace1.tsql where n1 = 1 and n1 is not null"), BindableTableScanOp.class);
ScanStatement statement = (ScanStatement) plan.getStatement();
Projection projection = statement.getProjection();
assertThat(projection, instanceOf(IdentityProjection.class));
SQLRecordPredicate predicate = (SQLRecordPredicate) statement.getPredicate();
assertThat(predicate.getWhere(), instanceOf(CompiledEqualsExpression.class));
CompiledEqualsExpression equals = (CompiledEqualsExpression) predicate.getWhere();
assertThat(equals.getLeft(), instanceOf(AccessCurrentRowExpression.class));
assertThat(equals.getRight(), instanceOf(ConstantExpression.class));
}
if (manager.getPlanner() instanceof JSQLParserPlanner) {
assertInstanceOf(plan(manager, "select * from tblspace1.tsql"), BindableTableScanOp.class);
} else {
assertInstanceOf(plan(manager, "select * from tblspace1.tsql"), TableScanOp.class);
}
assertInstanceOf(plan(manager, "select * from tblspace1.tsql where n1=1"), BindableTableScanOp.class);
assertInstanceOf(plan(manager, "select n1 from tblspace1.tsql"), BindableTableScanOp.class);
assertInstanceOf(plan(manager, "update tblspace1.tsql set n1=? where k1=?"), SimpleUpdateOp.class);
assertInstanceOf(plan(manager, "update tblspace1.tsql set n1=? where k1=? and n1=?"), SimpleUpdateOp.class);
if (manager.isFullSQLSupportEnabled()) {
assertInstanceOf(plan(manager, "update tblspace1.tsql set n1=?" + " where n1 in (select b.n1*2 from tblspace1.tsql b)"), UpdateOp.class);
}
assertInstanceOf(plan(manager, "delete from tblspace1.tsql where k1=?"), SimpleDeleteOp.class);
assertInstanceOf(plan(manager, "delete from tblspace1.tsql where k1=? and n1=?"), SimpleDeleteOp.class);
if (manager.isFullSQLSupportEnabled()) {
assertInstanceOf(plan(manager, "delete from tblspace1.tsql where n1 in (select b.n1*2 from tblspace1.tsql b)"), DeleteOp.class);
}
assertInstanceOf(plan(manager, "INSERT INTO tblspace1.tsql (k1,n1) values(?,?)"), SimpleInsertOp.class);
assertInstanceOf(plan(manager, "INSERT INTO tblspace1.tsql (k1,n1) values(?,?),(?,?)"), InsertOp.class);
if (manager.getPlanner() instanceof JSQLParserPlanner) {
assertInstanceOf(plan(manager, "select * from tblspace1.tsql order by k1"), SortedBindableTableScanOp.class);
} else {
assertInstanceOf(plan(manager, "select * from tblspace1.tsql order by k1"), SortedTableScanOp.class);
}
assertInstanceOf(plan(manager, "select k1 from tblspace1.tsql order by k1"), SortedBindableTableScanOp.class);
assertInstanceOf(plan(manager, "select k1 from tblspace1.tsql order by k1 limit 10"), LimitedSortedBindableTableScanOp.class);
{
BindableTableScanOp plan = assertInstanceOf(plan(manager, "select * from tblspace1.tsql where k1=?"), BindableTableScanOp.class);
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(IdentityProjection.class));
assertNull(plan.getStatement().getComparator());
}
{
SortedBindableTableScanOp plan = assertInstanceOf(plan(manager, "select n1,k1 from tblspace1.tsql order by n1"), SortedBindableTableScanOp.class);
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(ZeroCopyProjection.class));
ZeroCopyProjection zero = (ZeroCopyProjection) projection;
assertArrayEquals(new String[] { "n1", "k1" }, zero.getFieldNames());
assertEquals("n1", zero.getColumns()[0].name);
assertEquals("k1", zero.getColumns()[1].name);
TupleComparator comparator = plan.getStatement().getComparator();
System.out.println("comparator:" + comparator);
assertThat(comparator, instanceOf(SortOp.class));
SortOp sortOp = (SortOp) comparator;
assertFalse(sortOp.isOnlyPrimaryKeyAndAscending());
}
{
SortedBindableTableScanOp plan = assertInstanceOf(plan(manager, "select n1,k1 from tblspace1.tsql order by k1"), SortedBindableTableScanOp.class);
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(ZeroCopyProjection.class));
ZeroCopyProjection zero = (ZeroCopyProjection) projection;
assertArrayEquals(new String[] { "n1", "k1" }, zero.getFieldNames());
assertEquals("n1", zero.getColumns()[0].name);
assertEquals("k1", zero.getColumns()[1].name);
TupleComparator comparator = plan.getStatement().getComparator();
System.out.println("comparator:" + comparator);
assertThat(comparator, instanceOf(SortOp.class));
SortOp sortOp = (SortOp) comparator;
assertTrue(sortOp.isOnlyPrimaryKeyAndAscending());
}
{
SimpleScanOp plan = (SimpleScanOp) plan(manager, "select * from tblspace1.tsql order by n1");
if (manager.getPlanner() instanceof JSQLParserPlanner) {
assertThat(plan, instanceOf(SortedBindableTableScanOp.class));
} else {
assertThat(plan, instanceOf(SortedTableScanOp.class));
}
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(IdentityProjection.class));
IdentityProjection zero = (IdentityProjection) projection;
assertArrayEquals(new String[] { "k1", "n1", "s1" }, zero.getFieldNames());
assertEquals("k1", zero.getColumns()[0].name);
assertEquals("n1", zero.getColumns()[1].name);
assertEquals("s1", zero.getColumns()[2].name);
TupleComparator comparator = plan.getStatement().getComparator();
System.out.println("comparator:" + comparator);
assertThat(comparator, instanceOf(SortOp.class));
SortOp sortOp = (SortOp) comparator;
assertFalse(sortOp.isOnlyPrimaryKeyAndAscending());
}
{
SimpleScanOp plan = (SimpleScanOp) plan(manager, "select * from tblspace1.tsql order by k1");
if (manager.getPlanner() instanceof JSQLParserPlanner) {
assertThat(plan, instanceOf(SortedBindableTableScanOp.class));
} else {
assertThat(plan, instanceOf(SortedTableScanOp.class));
}
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(IdentityProjection.class));
IdentityProjection zero = (IdentityProjection) projection;
assertArrayEquals(new String[] { "k1", "n1", "s1" }, zero.getFieldNames());
assertEquals("k1", zero.getColumns()[0].name);
assertEquals("n1", zero.getColumns()[1].name);
assertEquals("s1", zero.getColumns()[2].name);
TupleComparator comparator = plan.getStatement().getComparator();
System.out.println("comparator:" + comparator);
assertThat(comparator, instanceOf(SortOp.class));
SortOp sortOp = (SortOp) comparator;
assertTrue(sortOp.isOnlyPrimaryKeyAndAscending());
}
}
}
use of herddb.mem.MemoryMetadataStorageManager in project herddb by diennea.
the class CalcitePlannerTest method zeroCopyProjectionTest.
@Test
public void zeroCopyProjectionTest() throws Exception {
String nodeId = "localhost";
try (DBManager manager = new DBManager("localhost", new MemoryMetadataStorageManager(), new MemoryDataStorageManager(), new MemoryCommitLogManager(), null, null)) {
manager.start();
CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.waitForTablespace("tblspace1", 10000);
execute(manager, "CREATE TABLE tblspace1.tsql (k1 string primary key," + "s1 string)", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.tsql (k1 ," + "s1) values('testk1','tests1')", Collections.emptyList());
try (DataScanner scan = scan(manager, "SELECT * FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(DataAccessorForFullRecord.class));
assertEquals("k1", record.getFieldNames()[0]);
assertEquals("s1", record.getFieldNames()[1]);
assertEquals(RawString.of("testk1"), record.get(0));
assertEquals(RawString.of("tests1"), record.get(1));
assertEquals(RawString.of("testk1"), record.get("k1"));
assertEquals(RawString.of("tests1"), record.get("s1"));
}
try (DataScanner scan = scan(manager, "SELECT k1,s1 FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(DataAccessorForFullRecord.class));
assertEquals("k1", record.getFieldNames()[0]);
assertEquals("s1", record.getFieldNames()[1]);
assertEquals(RawString.of("testk1"), record.get(0));
assertEquals(RawString.of("tests1"), record.get(1));
assertEquals(RawString.of("testk1"), record.get("k1"));
assertEquals(RawString.of("tests1"), record.get("s1"));
}
try (DataScanner scan = scan(manager, "SELECT s1,k1 FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(ZeroCopyProjection.RuntimeProjectedDataAccessor.class));
assertEquals("k1", record.getFieldNames()[1]);
assertEquals("s1", record.getFieldNames()[0]);
assertEquals(RawString.of("testk1"), record.get(1));
assertEquals(RawString.of("tests1"), record.get(0));
assertEquals(RawString.of("testk1"), record.get("k1"));
assertEquals(RawString.of("tests1"), record.get("s1"));
}
try (DataScanner scan = scan(manager, "SELECT s1 FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(RuntimeProjectedDataAccessor.class));
assertEquals("s1", record.getFieldNames()[0]);
assertEquals(RawString.of("tests1"), record.get(0));
assertEquals(RawString.of("tests1"), record.get("s1"));
}
try (DataScanner scan = scan(manager, "SELECT k1 FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(RuntimeProjectedDataAccessor.class));
assertEquals("k1", record.getFieldNames()[0]);
assertEquals(RawString.of("testk1"), record.get(0));
assertEquals(RawString.of("testk1"), record.get("k1"));
}
}
}
Aggregations