Examples of StatementSplitter


Examples of com.facebook.presto.sql.parser.StatementSplitter

    private List<String> loadQueries()
    {
        try {
            String query = Files.toString(new File(file), Charsets.UTF_8);
            StatementSplitter splitter = new StatementSplitter(query + ";");
            return ImmutableList.copyOf(transform(splitter.getCompleteStatements(), new Function<Statement, String>()
            {
                @Override
                public String apply(Statement statement)
                {
                    return statement.statement();
View Full Code Here

Examples of com.facebook.presto.sql.parser.StatementSplitter

                // not a command, add line to buffer
                buffer.append(line).append("\n");

                // execute any complete statements
                String sql = buffer.toString();
                StatementSplitter splitter = new StatementSplitter(sql, ImmutableSet.of(";", "\\G"));
                for (Statement split : splitter.getCompleteStatements()) {
                    Optional<Object> statement = getParsedStatement(split.statement());
                    if (statement.isPresent() && isSessionParameterChange(statement.get())) {
                        session = processSessionParameterChange(statement.get(), session);
                        queryRunner.setSession(session);
                        tableNameCompleter.populateCache();
                    }
                    else {
                        OutputFormat outputFormat = OutputFormat.ALIGNED;
                        if (split.terminator().equals("\\G")) {
                            outputFormat = OutputFormat.VERTICAL;
                        }

                        process(queryRunner, split.statement(), outputFormat, true);
                    }
                    reader.getHistory().add(squeezeStatement(split.statement()) + split.terminator());
                }

                // replace buffer with trailing partial statement
                buffer = new StringBuilder();
                String partial = splitter.getPartialStatement();
                if (!partial.isEmpty()) {
                    buffer.append(partial).append('\n');
                }
            }
        }
View Full Code Here

Examples of com.facebook.presto.sql.parser.StatementSplitter

        return statement instanceof UseCollection;
    }

    private static void executeCommand(QueryRunner queryRunner, String query, OutputFormat outputFormat)
    {
        StatementSplitter splitter = new StatementSplitter(query);
        for (Statement split : splitter.getCompleteStatements()) {
            if (!isEmptyStatement(split.statement())) {
                process(queryRunner, split.statement(), outputFormat, false);
            }
        }
        if (!isEmptyStatement(splitter.getPartialStatement())) {
            System.err.println("Non-terminated statement: " + splitter.getPartialStatement());
        }
    }
View Full Code Here

Examples of com.facebook.presto.sql.parser.StatementSplitter

    private List<String> loadQueries()
    {
        try {
            String query = Files.toString(new File(file), Charsets.UTF_8);
            StatementSplitter splitter = new StatementSplitter(query + ";");
            return ImmutableList.copyOf(transform(splitter.getCompleteStatements(), new Function<Statement, String>()
            {
                @Override
                public String apply(Statement statement)
                {
                    return statement.statement();
View Full Code Here

Examples of com.facebook.presto.sql.parser.StatementSplitter

    private List<String> loadQueries()
    {
        try {
            String query = Files.toString(new File(file), Charsets.UTF_8);
            StatementSplitter splitter = new StatementSplitter(query + ";");
            return ImmutableList.copyOf(transform(splitter.getCompleteStatements(), new Function<Statement, String>()
            {
                @Override
                public String apply(Statement statement)
                {
                    return statement.statement();
View Full Code Here

Examples of com.facebook.presto.sql.parser.StatementSplitter

                // not a command, add line to buffer
                buffer.append(line).append("\n");

                // execute any complete statements
                String sql = buffer.toString();
                StatementSplitter splitter = new StatementSplitter(sql, ImmutableSet.of(";", "\\G"));
                for (Statement split : splitter.getCompleteStatements()) {
                    Optional<Object> statement = getParsedStatement(split.statement());
                    if (statement.isPresent() && isSessionParameterChange(statement.get())) {
                        session = processSessionParameterChange(statement.get(), session);
                        queryRunner.setSession(session);
                        tableNameCompleter.populateCache();
                    }
                    else {
                        OutputFormat outputFormat = OutputFormat.ALIGNED;
                        if (split.terminator().equals("\\G")) {
                            outputFormat = OutputFormat.VERTICAL;
                        }

                        process(queryRunner, split.statement(), outputFormat, true);
                    }
                    reader.getHistory().add(squeezeStatement(split.statement()) + split.terminator());
                }

                // replace buffer with trailing partial statement
                buffer = new StringBuilder();
                String partial = splitter.getPartialStatement();
                if (!partial.isEmpty()) {
                    buffer.append(partial).append('\n');
                }
            }
        }
View Full Code Here

Examples of com.facebook.presto.sql.parser.StatementSplitter

        return statement instanceof UseCollection;
    }

    private static void executeCommand(QueryRunner queryRunner, String query, OutputFormat outputFormat)
    {
        StatementSplitter splitter = new StatementSplitter(query);
        for (Statement split : splitter.getCompleteStatements()) {
            if (!isEmptyStatement(split.statement())) {
                process(queryRunner, split.statement(), outputFormat, false);
            }
        }
        if (!isEmptyStatement(splitter.getPartialStatement())) {
            System.err.println("Non-terminated statement: " + splitter.getPartialStatement());
        }
    }
View Full Code Here

Examples of org.jboss.arquillian.persistence.spi.script.StatementSplitter

   private void executeScript(String script)
   {
      try
      {
         final StatementSplitter statementSplitter = new StatementSplitterResolver(scriptConfigurationInstance.get()).resolve();
         final ScriptExecutor scriptExecutor = new ScriptExecutor(databaseConnection.get().getConnection(), scriptConfigurationInstance.get(), statementSplitter);
         scriptExecutor.execute(script);
      }
      catch (SQLException e)
      {
View Full Code Here

Examples of org.jboss.arquillian.persistence.spi.script.StatementSplitter

   }

   public StatementSplitter resolve()
   {
      final String sqlDialect = scriptingConfiguration.getSqlDialect();
      StatementSplitter resolved = null;
      final Collection<StatementSplitter> statementSplitters = new JavaSPIExtensionLoader().all(Thread.currentThread().getContextClassLoader(), StatementSplitter.class);
      for (StatementSplitter statementSplitter : statementSplitters)
      {
         if (statementSplitter.supports().equalsIgnoreCase(sqlDialect))
         {
            if (resolved != null)
            {
               throw new IllegalStateException("Found multiple implementations of " + StatementSplitter.class.getName()
                     + " for specified dialect " + sqlDialect);
            }
            resolved = statementSplitter;
            resolved.setStatementDelimiter(scriptingConfiguration.getSqlStatementDelimiter());
         }
      }

      if (resolved == null)
      {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.