/*
* JBoss, Home of Professional Open Source.
* See the COPYRIGHT.txt file distributed with this work for information
* regarding copyright ownership. Some portions may be licensed
* to Red Hat, Inc. under one or more contributor license agreements.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
package org.teiid.query.processor;
import static org.junit.Assert.*;
import static org.teiid.query.processor.TestProcessor.*;
import java.util.Arrays;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import org.teiid.query.unittest.RealMetadataFactory;
@SuppressWarnings("nls")
public class TestCommonTableOptimizations {
@Test public void testDuplicateSourceQuery() {
String sql = "SELECT e1 FROM pm1.g1 union all select e1 from pm1.g1"; //$NON-NLS-1$
List<?>[] expected = new List[] {
Arrays.asList("a"), //$NON-NLS-1$
Arrays.asList("b"), //$NON-NLS-1$
Arrays.asList("a"), //$NON-NLS-1$
Arrays.asList("b"), //$NON-NLS-1$
};
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT pm1.g1.e1 FROM pm1.g1", new List<?>[] {Arrays.asList("a"), Arrays.asList("b")});
ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
helpProcess(plan, dataManager, expected);
assertEquals(3, dataManager.getCommandHistory().size());
}
@Ignore
@Test public void testDuplicateSimpleQuery() {
String sql = "SELECT e1 FROM pm1.g1 union all select e2 from pm1.g1"; //$NON-NLS-1$
List<?>[] expected = new List[] {
Arrays.asList("a"), //$NON-NLS-1$
Arrays.asList("b"), //$NON-NLS-1$
Arrays.asList("a"), //$NON-NLS-1$
Arrays.asList("b"), //$NON-NLS-1$
};
HardcodedDataManager dataManager = new HardcodedDataManager();
dataManager.addData("SELECT pm1.g1.e1 FROM pm1.g1", new List<?>[] {Arrays.asList("a"), Arrays.asList("b")});
ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
helpProcess(plan, dataManager, expected);
assertEquals(3, dataManager.getCommandHistory().size());
}
}