Package mondrian.spi

Examples of mondrian.spi.Dialect


    public void testToStringForMultipleGroupingSetsSql() {
        if (!isGroupingSetsSupported()) {
            return;
        }
        final Dialect dialect = getTestContext().getDialect();
        for (boolean b : new boolean[]{false, true}) {
            SqlQuery sqlQuery = new SqlQuery(dialect, b);
            sqlQuery.addSelect("c0", null);
            sqlQuery.addSelect("c1", null);
            sqlQuery.addSelect("c2", null);
            sqlQuery.addSelect("m1", null, "m1");
            sqlQuery.addFromTable("s", "t1", "t1alias", null, null, true);
            sqlQuery.addWhere("a=b");
            sqlQuery.addGroupingFunction("c0");
            sqlQuery.addGroupingFunction("c1");
            sqlQuery.addGroupingFunction("c2");
            ArrayList<String> groupingSetlist1 = new ArrayList<String>();
            groupingSetlist1.add("c0");
            groupingSetlist1.add("c1");
            groupingSetlist1.add("c2");
            sqlQuery.addGroupingSet(groupingSetlist1);
            ArrayList<String> groupingsetsList2 = new ArrayList<String>();
            groupingsetsList2.add("c1");
            groupingsetsList2.add("c2");
            sqlQuery.addGroupingSet(groupingsetsList2);
            String expected;
            if (b) {
                expected =
                    "select\n"
                    + "    c0 as \"c0\",\n"
                    + "    c1 as \"c1\",\n"
                    + "    c2 as \"c2\",\n"
                    + "    m1 as \"m1\",\n"
                    + "    grouping(c0) as \"g0\",\n"
                    + "    grouping(c1) as \"g1\",\n"
                    + "    grouping(c2) as \"g2\"\n"
                    + "from\n"
                    + "    \"s\".\"t1\" =as= \"t1alias\"\n"
                    + "where\n"
                    + "    a=b\n"
                    + "group by grouping sets (\n"
                    + "    (c0, c1, c2),\n"
                    + "    (c1, c2))";
            } else {
                expected =
                    "select c0 as \"c0\", c1 as \"c1\", c2 as \"c2\", m1 as \"m1\", "
                    + "grouping(c0) as \"g0\", grouping(c1) as \"g1\", grouping(c2) as \"g2\" "
                    + "from \"s\".\"t1\" =as= \"t1alias\" where a=b "
                    + "group by grouping sets ((c0, c1, c2), (c1, c2))";
            }
            assertEquals(
                dialectize(dialect.getDatabaseProduct(), expected),
                dialectize(
                    sqlQuery.getDialect().getDatabaseProduct(),
                    sqlQuery.toString()));
        }
    }
View Full Code Here


     *
     * <p>Mondrian only generates SQL DOUBLE values in a special format for
     * LucidDB; therefore, this test is a no-op on other databases.
     */
    public void testDoubleInList() {
        final Dialect dialect = getTestContext().getDialect();
        if (dialect.getDatabaseProduct() != Dialect.DatabaseProduct.LUCIDDB) {
            return;
        }

        propSaver.set(prop.IgnoreInvalidMembers, true);
        propSaver.set(prop.IgnoreInvalidMembersDuringQuery, true);
View Full Code Here

        throws SQLException, NamingException
    {
        // use the datasource property to connect to the database
        Util.PropertyList properties =
            TestContext.instance().getConnectionProperties().clone();
        final Dialect dialect = TestContext.instance().getDialect();
        if (dialect.getDatabaseProduct() == Dialect.DatabaseProduct.ACCESS) {
            // Access doesn't accept user/password, so this test is pointless.
            return;
        }

        final String jdbcUser =
            properties.get(RolapConnectionProperties.JdbcUser.name());
        final String jdbcPassword =
            properties.get(RolapConnectionProperties.JdbcPassword.name());
        if (jdbcUser == null || jdbcPassword == null) {
            // Can only run this test if username and password are explicit.
            return;
        }

        // Define a data source with bogus user and password.
        properties.put(
            RolapConnectionProperties.JdbcUser.name(),
            "bogususer");
        properties.put(
            RolapConnectionProperties.JdbcPassword.name(),
            "boguspassword");
        properties.put(
            RolapConnectionProperties.PoolNeeded.name(),
            "false");
        final StringBuilder buf = new StringBuilder();
        final DataSource dataSource =
            RolapConnection.createDataSource(null, properties, buf);
        final String desc = buf.toString();
        assertTrue(desc, desc.startsWith("Jdbc="));
        assertTrue(
            desc,
            desc.indexOf("JdbcUser=bogususer; JdbcPassword=boguspassword")
            >= 0);
        final String jndiName = "jndiDataSource";
        THREAD_INITIAL_CONTEXT.set(
            new InitialContext() {
                public Object lookup(String str) {
                    return str.equals(jndiName)
                        ? dataSource
                        : null;
                }
            }
       );

        // Create a property list that we will use for the actual mondrian
        // connection. Replace the original JDBC info with the data source we
        // just created.
        final Util.PropertyList properties2 = new Util.PropertyList();
        for (Pair<String, String> entry : properties) {
            properties2.put(entry.getKey(), entry.getValue());
        }
        properties2.remove(RolapConnectionProperties.Jdbc.name());
        properties2.put(
            RolapConnectionProperties.DataSource.name(),
            jndiName);

        // With JdbcUser and JdbcPassword credentials in the mondrian connect
        // string, the data source's "user" and "password" properties are
        // overridden and the connection succeeds.
        properties2.put(
            RolapConnectionProperties.JdbcUser.name(),
            jdbcUser);
        properties2.put(
            RolapConnectionProperties.JdbcPassword.name(),
            jdbcPassword);
        mondrian.olap.Connection connection = null;
        try {
            connection =
                DriverManager.getConnection(properties2, null);
            Query query = connection.parseQuery("select from [Sales]");
            final Result result = connection.execute(query);
            assertNotNull(result);
        } finally {
            if (connection != null) {
                connection.close();
                connection = null;
            }
        }

        // If we don't specify JdbcUser and JdbcPassword in the mondrian
        // connection properties, mondrian uses the data source's
        // bogus credentials, and the connection fails.
        properties2.remove(RolapConnectionProperties.JdbcUser.name());
        properties2.remove(RolapConnectionProperties.JdbcPassword.name());
        for (String poolNeeded : Arrays.asList("false", "true")) {
            // Important to test with & without pooling. Connection pools
            // typically do not let you change user, so it's important that
            // mondrian handles these right.
            properties2.put(
                RolapConnectionProperties.PoolNeeded.name(), poolNeeded);
            try {
                connection = DriverManager.getConnection(properties2, null);
                fail("Expected exception");
            } catch (MondrianException e) {
                final String s = TestContext.getStackTrace(e);
                assertTrue(
                    s,
                    s.indexOf(
                        "Error while creating SQL connection: "
                        + "DataSource=jndiDataSource") >= 0);
                switch (dialect.getDatabaseProduct()) {
                case DERBY:
                    assertTrue(
                        s,
                        s.indexOf(
                            "Caused by: java.sql.SQLException: "
View Full Code Here

        }

        RolapCube cube =
            (RolapCube)context.executeQuery("select from sales")
                .getQuery().getCube();
        Dialect dialect = cube.getStar().getSqlQueryDialect();

        if (!dialect.getDatabaseProduct()
            .equals(Dialect.DatabaseProduct.MYSQL)
            && !dialect.getDatabaseProduct()
                .equals(Dialect.DatabaseProduct.ORACLE))
        {
            return;
        }
View Full Code Here

        String testCaseName, String filename, String content)
    {
        if ("testWithFilter".equals(testCaseName)
            && filename.equals("response"))
        {
            Dialect dialect = TestContext.instance().getDialect();
            switch (dialect.getDatabaseProduct()) {
            case DERBY:
                content = Util.replace(
                    content,
                    "<Value xsi:type=\"xsd:double\">",
                    "<Value xsi:type=\"xsd:int\">");
View Full Code Here

        }
        return content;
    }

    public void testCognosMDXSuiteHR_001() throws Exception {
        Dialect dialect = TestContext.instance().getDialect();
        switch (dialect.getDatabaseProduct()) {
        case DERBY:
            // Derby gives right answer, but many cells have wrong xsi:type.
            return;
        }
        executeMDX();
View Full Code Here

        }
        executeMDX();
    }

    public void testCognosMDXSuiteHR_002() throws Exception {
        Dialect dialect = TestContext.instance().getDialect();
        switch (dialect.getDatabaseProduct()) {
        case DERBY:
            // Derby gives right answer, but many cells have wrong xsi:type.
            return;
        }
        executeMDX();
View Full Code Here

    public CsvDBTestCase(String name) {
        super(name);
    }

    protected final boolean isApplicable() {
        final Dialect dialect = TestContext.instance().getDialect();
        return dialect.allowsDdl()
            && dialect.getDatabaseProduct()
            != Dialect.DatabaseProduct.INFOBRIGHT;
    }
View Full Code Here

    /**
     * Tests that a #null member on a Hiearchy Level of type String can
     * still be looked up when case sensitive is off.
     */
    public void testCaseInsensitiveNullMember() {
        final Dialect dialect = getTestContext().getDialect();
        if (dialect.getDatabaseProduct() == Dialect.DatabaseProduct.LUCIDDB) {
            // TODO jvs 29-Nov-2006:  LucidDB is strict about
            // null literals (type can't be inferred in this context);
            // maybe enhance the inline table to use the columndef
            // types to apply a CAST.
            return;
View Full Code Here

        final List<String> key = Arrays.asList(catalog, schema, table);
        int rowCount = -1;
        if (tableMap.containsKey(key)) {
            rowCount = tableMap.get(key);
        } else {
            final Dialect dialect = star.getSqlQueryDialect();
            final List<StatisticsProvider> statisticsProviders =
                dialect.getStatisticsProviders();
            final Execution execution =
                new Execution(
                    star.getSchema().getInternalConnection()
                        .getInternalStatement(),
                    0);
View Full Code Here

TOP

Related Classes of mondrian.spi.Dialect

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.