
package org.apache.calcite.tools;

import org.apache.calcite.rel.RelNode;

import com.google.common.base.Throwables;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/** Implementations of {@link RelRunner}. */
public class RelRunners {
  private RelRunners() {}

  /** Runs a relational expression by creating a JDBC connection. */
  public static PreparedStatement run(RelNode rel) {
    try (Connection connection = DriverManager.getConnection("jdbc:calcite:")) {
      final RelRunner runner = connection.unwrap(RelRunner.class);
      return runner.prepare(rel);
    } catch (SQLException e) {
      throw Throwables.propagate(e);
    }
  }
}

// End RelRunners.java
