spuerx 9 лет назад
Родитель
Сommit
aed4a02e2a

+ 67 - 0
src/main/java/org/elasticsearch/jdbc/AbstractDataSource.java

@@ -0,0 +1,67 @@
+package org.elasticsearch.jdbc;
+
+
+import javax.sql.DataSource;
+import java.io.PrintWriter;
+import java.sql.SQLException;
+import java.util.logging.Logger;
+
+
+public abstract class AbstractDataSource implements DataSource {
+
+    /**
+     * Returns 0, indicating the default system timeout is to be used.
+     */
+    public int getLoginTimeout() throws SQLException {
+        return 0;
+    }
+
+    /**
+     * Setting a login timeout is not supported.
+     */
+    public void setLoginTimeout(int timeout) throws SQLException {
+        throw new UnsupportedOperationException("setLoginTimeout");
+    }
+
+    /**
+     * LogWriter methods are not supported.
+     */
+    public PrintWriter getLogWriter() {
+        throw new UnsupportedOperationException("getLogWriter");
+    }
+
+    /**
+     * LogWriter methods are not supported.
+     */
+    public void setLogWriter(PrintWriter pw) throws SQLException {
+        throw new UnsupportedOperationException("setLogWriter");
+    }
+
+
+    //---------------------------------------------------------------------
+    // Implementation of JDBC 4.0's Wrapper interface
+    //---------------------------------------------------------------------
+
+    @SuppressWarnings("unchecked")
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        if (iface.isInstance(this)) {
+            return (T) this;
+        }
+        throw new SQLException("DataSource of type [" + getClass().getName() +
+                "] cannot be unwrapped as [" + iface.getName() + "]");
+    }
+
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        return iface.isInstance(this);
+    }
+
+
+    //---------------------------------------------------------------------
+    // Implementation of JDBC 4.1's getParentLogger method
+    //---------------------------------------------------------------------
+
+    public Logger getParentLogger() {
+        return Logger.getLogger(Logger.GLOBAL_LOGGER_NAME);
+    }
+
+}

+ 140 - 0
src/main/java/org/elasticsearch/jdbc/AbstractDriverBasedDataSource.java

@@ -0,0 +1,140 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.Properties;
+
+public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
+
+    private String url;
+
+    private String username;
+
+    private String password;
+
+    private Properties connectionProperties;
+
+
+    public void setUrl(String url) {
+        this.url = url.trim();
+    }
+
+    /**
+     * Return the JDBC URL to use for connecting through the Driver.
+     */
+    public String getUrl() {
+        return this.url;
+    }
+
+    /**
+     * Set the JDBC username to use for connecting through the Driver.
+     *
+     * @see java.sql.Driver#connect(String, java.util.Properties)
+     */
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    /**
+     * Return the JDBC username to use for connecting through the Driver.
+     */
+    public String getUsername() {
+        return this.username;
+    }
+
+    /**
+     * Set the JDBC password to use for connecting through the Driver.
+     *
+     * @see java.sql.Driver#connect(String, java.util.Properties)
+     */
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /**
+     * Return the JDBC password to use for connecting through the Driver.
+     */
+    public String getPassword() {
+        return this.password;
+    }
+
+    /**
+     * Specify arbitrary connection properties as key/value pairs,
+     * to be passed to the Driver.
+     * <p>Can also contain "user" and "password" properties. However,
+     * any "username" and "password" bean properties specified on this
+     * DataSource will override the corresponding connection properties.
+     *
+     * @see java.sql.Driver#connect(String, java.util.Properties)
+     */
+    public void setConnectionProperties(Properties connectionProperties) {
+        this.connectionProperties = connectionProperties;
+    }
+
+    /**
+     * Return the connection properties to be passed to the Driver, if any.
+     */
+    public Properties getConnectionProperties() {
+        return this.connectionProperties;
+    }
+
+
+    /**
+     * This implementation delegates to {@code getConnectionFromDriver},
+     * using the default username and password of this DataSource.
+     *
+     * @see #getConnectionFromDriver(String, String)
+     * @see #setUsername
+     * @see #setPassword
+     */
+    public Connection getConnection() throws SQLException {
+        return getConnectionFromDriver(getUsername(), getPassword());
+    }
+
+    /**
+     * This implementation delegates to {@code getConnectionFromDriver},
+     * using the given username and password.
+     *
+     * @see #getConnectionFromDriver(String, String)
+     */
+    public Connection getConnection(String username, String password) throws SQLException {
+        return getConnectionFromDriver(username, password);
+    }
+
+
+    /**
+     * Build properties for the Driver, including the given username and password (if any),
+     * and obtain a corresponding Connection.
+     *
+     * @param username the name of the user
+     * @param password the password to use
+     * @return the obtained Connection
+     * @throws SQLException in case of failure
+     * @see java.sql.Driver#connect(String, java.util.Properties)
+     */
+    protected Connection getConnectionFromDriver(String username, String password) throws SQLException {
+        Properties mergedProps = new Properties();
+        Properties connProps = getConnectionProperties();
+        if (connProps != null) {
+            mergedProps.putAll(connProps);
+        }
+        if (username != null) {
+            mergedProps.setProperty("user", username);
+        }
+        if (password != null) {
+            mergedProps.setProperty("password", password);
+        }
+        return getConnectionFromDriver(mergedProps);
+    }
+
+    /**
+     * Obtain a Connection using the given properties.
+     * <p>Template method to be implemented by subclasses.
+     *
+     * @param props the merged connection properties
+     * @return the obtained Connection
+     * @throws SQLException in case of failure
+     */
+    protected abstract Connection getConnectionFromDriver(Properties props) throws SQLException;
+
+}

+ 16 - 0
src/main/java/org/elasticsearch/jdbc/ConnectionProxy.java

@@ -0,0 +1,16 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.Connection;
+
+public interface ConnectionProxy extends Connection {
+
+    /**
+     * Return the target Connection of this proxy.
+     * <p>This will typically be the native driver Connection
+     * or a wrapper from a connection pool.
+     *
+     * @return the underlying Connection (never {@code null})
+     */
+    Connection getTargetConnection();
+
+}

+ 118 - 0
src/main/java/org/elasticsearch/jdbc/DriverManagerDataSource.java

@@ -0,0 +1,118 @@
+package org.elasticsearch.jdbc;
+
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Properties;
+
+public class DriverManagerDataSource extends AbstractDriverBasedDataSource {
+
+    /**
+     * Constructor for bean-style configuration.
+     */
+    public DriverManagerDataSource() {
+    }
+
+    /**
+     * Create a new DriverManagerDataSource with the given JDBC URL,
+     * not specifying a username or password for JDBC access.
+     *
+     * @param url the JDBC URL to use for accessing the DriverManager
+     * @see java.sql.DriverManager#getConnection(String)
+     */
+    public DriverManagerDataSource(String url) {
+        setUrl(url);
+    }
+
+    /**
+     * Create a new DriverManagerDataSource with the given standard
+     * DriverManager parameters.
+     *
+     * @param url      the JDBC URL to use for accessing the DriverManager
+     * @param username the JDBC username to use for accessing the DriverManager
+     * @param password the JDBC password to use for accessing the DriverManager
+     * @see java.sql.DriverManager#getConnection(String, String, String)
+     */
+    public DriverManagerDataSource(String url, String username, String password) {
+        setUrl(url);
+        setUsername(username);
+        setPassword(password);
+    }
+
+    /**
+     * Create a new DriverManagerDataSource with the given JDBC URL,
+     * not specifying a username or password for JDBC access.
+     *
+     * @param url      the JDBC URL to use for accessing the DriverManager
+     * @param conProps JDBC connection properties
+     * @see java.sql.DriverManager#getConnection(String)
+     */
+    public DriverManagerDataSource(String url, Properties conProps) {
+        setUrl(url);
+        setConnectionProperties(conProps);
+    }
+
+    @Deprecated
+    public DriverManagerDataSource(String driverClassName, String url, String username, String password) {
+        setDriverClassName(driverClassName);
+        setUrl(url);
+        setUsername(username);
+        setPassword(password);
+    }
+
+
+
+    public void setDriverClassName(String driverClassName) {
+        String driverClassNameToUse = driverClassName.trim();
+        try {
+            Class.forName(driverClassNameToUse, true, getDefaultClassLoader());
+        }
+        catch (ClassNotFoundException ex) {
+            throw new IllegalStateException("Could not load JDBC driver class [" + driverClassNameToUse + "]", ex);
+        }
+    }
+
+
+    public static ClassLoader getDefaultClassLoader() {
+        ClassLoader cl = null;
+        try {
+            cl = Thread.currentThread().getContextClassLoader();
+        }
+        catch (Throwable ex) {
+            // Cannot access thread context ClassLoader - falling back...
+        }
+        if (cl == null) {
+            // No thread context class loader -> use class loader of this class.
+            cl = DriverManagerDataSource.class.getClassLoader();
+            if (cl == null) {
+                // getClassLoader() returning null indicates the bootstrap ClassLoader
+                try {
+                    cl = ClassLoader.getSystemClassLoader();
+                }
+                catch (Throwable ex) {
+                    // Cannot access system ClassLoader - oh well, maybe the caller can live with null...
+                }
+            }
+        }
+        return cl;
+    }
+
+    @Override
+    protected Connection getConnectionFromDriver(Properties props) throws SQLException {
+        String url = getUrl();
+
+        return getConnectionFromDriverManager(url, props);
+    }
+
+    /**
+     * Getting a Connection using the nasty static from DriverManager is extracted
+     * into a protected method to allow for easy unit testing.
+     *
+     * @see java.sql.DriverManager#getConnection(String, java.util.Properties)
+     */
+    protected Connection getConnectionFromDriverManager(String url, Properties props) throws SQLException {
+        return DriverManager.getConnection(url, props);
+    }
+
+}

Разница между файлами не показана из-за своего большого размера
+ 1526 - 0
src/main/java/org/elasticsearch/jdbc/ElasticConnection.java


+ 58 - 0
src/main/java/org/elasticsearch/jdbc/ElasticDriver.java

@@ -0,0 +1,58 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.*;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+public class ElasticDriver implements Driver {
+
+    private static final String ELASTIC_SEARCH_DRIVER_PREFIX = "jdbc:elastic:";
+
+    private static final ElasticDriver driverInstance;
+
+    static {
+        driverInstance = new ElasticDriver();
+        try {
+            DriverManager.registerDriver(driverInstance);
+        }
+        catch (SQLException ex) {
+            // ignore
+        }
+    }
+
+    @Override
+    public Connection connect(String url, Properties info) throws SQLException {
+        return new ElasticConnection();
+    }
+
+
+    @Override
+    public boolean acceptsURL(String url) throws SQLException {
+        return url != null && url.startsWith(ELASTIC_SEARCH_DRIVER_PREFIX);
+    }
+
+    @Override
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
+        return new DriverPropertyInfo[0];
+    }
+
+    @Override
+    public int getMajorVersion() {
+        return 1;
+    }
+
+    @Override
+    public int getMinorVersion() {
+        return 0;
+    }
+
+    @Override
+    public boolean jdbcCompliant() {
+        return true;
+    }
+
+    @Override
+    public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+        throw new UnsupportedOperationException("getParentLogger");
+    }
+}

+ 319 - 0
src/main/java/org/elasticsearch/jdbc/SingleConnectionDataSource.java

@@ -0,0 +1,319 @@
+package org.elasticsearch.jdbc;
+
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public class SingleConnectionDataSource extends DriverManagerDataSource implements SmartDataSource {
+
+    /**
+     * Create a close-suppressing proxy?
+     */
+    private boolean suppressClose;
+
+    /**
+     * Override auto-commit state?
+     */
+    private Boolean autoCommit;
+
+    /**
+     * Wrapped Connection
+     */
+    private Connection target;
+
+    /**
+     * Proxy Connection
+     */
+    private Connection connection;
+
+    /**
+     * Synchronization monitor for the shared Connection
+     */
+    private final Object connectionMonitor = new Object();
+
+
+    /**
+     * Constructor for bean-style configuration.
+     */
+    public SingleConnectionDataSource() {
+    }
+
+    /**
+     * Create a new SingleConnectionDataSource with the given standard
+     * DriverManager parameters.
+     *
+     * @param driverClassName the JDBC driver class name
+     * @param url             the JDBC URL to use for accessing the DriverManager
+     * @param username        the JDBC username to use for accessing the DriverManager
+     * @param password        the JDBC password to use for accessing the DriverManager
+     * @param suppressClose   if the returned Connection should be a
+     *                        close-suppressing proxy or the physical Connection
+     * @see java.sql.DriverManager#getConnection(String, String, String)
+     * @deprecated since Spring 2.5. Driver parameter usage is generally not recommended
+     * for a SingleConnectionDataSource. If you insist on using driver parameters
+     * directly, set up the Driver class manually before invoking this DataSource.
+     */
+    @Deprecated
+    public SingleConnectionDataSource(
+            String driverClassName, String url, String username, String password, boolean suppressClose) {
+
+        super(driverClassName, url, username, password);
+        this.suppressClose = suppressClose;
+    }
+
+    /**
+     * Create a new SingleConnectionDataSource with the given standard
+     * DriverManager parameters.
+     *
+     * @param url           the JDBC URL to use for accessing the DriverManager
+     * @param username      the JDBC username to use for accessing the DriverManager
+     * @param password      the JDBC password to use for accessing the DriverManager
+     * @param suppressClose if the returned Connection should be a
+     *                      close-suppressing proxy or the physical Connection
+     * @see java.sql.DriverManager#getConnection(String, String, String)
+     */
+    public SingleConnectionDataSource(String url, String username, String password, boolean suppressClose) {
+        super(url, username, password);
+        this.suppressClose = suppressClose;
+    }
+
+    /**
+     * Create a new SingleConnectionDataSource with the given standard
+     * DriverManager parameters.
+     *
+     * @param url           the JDBC URL to use for accessing the DriverManager
+     * @param suppressClose if the returned Connection should be a
+     *                      close-suppressing proxy or the physical Connection
+     * @see java.sql.DriverManager#getConnection(String, String, String)
+     */
+    public SingleConnectionDataSource(String url, boolean suppressClose) {
+        super(url);
+        this.suppressClose = suppressClose;
+    }
+
+    /**
+     * Create a new SingleConnectionDataSource with a given Connection.
+     *
+     * @param target        underlying target Connection
+     * @param suppressClose if the Connection should be wrapped with a Connection that
+     *                      suppresses {@code close()} calls (to allow for normal {@code close()}
+     *                      usage in applications that expect a pooled Connection but do not know our
+     *                      SmartDataSource interface)
+     */
+    public SingleConnectionDataSource(Connection target, boolean suppressClose) {
+        this.target = target;
+        this.suppressClose = suppressClose;
+        this.connection = (suppressClose ? getCloseSuppressingConnectionProxy(target) : target);
+    }
+
+
+    /**
+     * Set whether the returned Connection should be a close-suppressing proxy
+     * or the physical Connection.
+     */
+    public void setSuppressClose(boolean suppressClose) {
+        this.suppressClose = suppressClose;
+    }
+
+    /**
+     * Return whether the returned Connection will be a close-suppressing proxy
+     * or the physical Connection.
+     */
+    protected boolean isSuppressClose() {
+        return this.suppressClose;
+    }
+
+    /**
+     * Set whether the returned Connection's "autoCommit" setting should be overridden.
+     */
+    public void setAutoCommit(boolean autoCommit) {
+        this.autoCommit = (autoCommit);
+    }
+
+    /**
+     * Return whether the returned Connection's "autoCommit" setting should be overridden.
+     *
+     * @return the "autoCommit" value, or {@code null} if none to be applied
+     */
+    protected Boolean getAutoCommitValue() {
+        return this.autoCommit;
+    }
+
+
+    @Override
+    public Connection getConnection() throws SQLException {
+        synchronized (this.connectionMonitor) {
+            if (this.connection == null) {
+                // No underlying Connection -> lazy init via DriverManager.
+                initConnection();
+            }
+            if (this.connection.isClosed()) {
+                throw new SQLException(
+                        "Connection was closed in SingleConnectionDataSource. Check that user code checks " +
+                                "shouldClose() before closing Connections, or set 'suppressClose' to 'true'");
+            }
+            return this.connection;
+        }
+    }
+
+    /**
+     * Specifying a custom username and password doesn't make sense
+     * with a single Connection. Returns the single Connection if given
+     * the same username and password; throws a SQLException else.
+     */
+    @Override
+    public Connection getConnection(String username, String password) throws SQLException {
+        return getConnection();
+    }
+
+    /**
+     * This is a single Connection: Do not close it when returning to the "pool".
+     */
+    public boolean shouldClose(Connection con) {
+        synchronized (this.connectionMonitor) {
+            return (con != this.connection && con != this.target);
+        }
+    }
+
+    /**
+     * Close the underlying Connection.
+     * The provider of this DataSource needs to care for proper shutdown.
+     * <p>As this bean implements DisposableBean, a bean factory will
+     * automatically invoke this on destruction of its cached singletons.
+     */
+    public void destroy() {
+        synchronized (this.connectionMonitor) {
+            closeConnection();
+        }
+    }
+
+
+    /**
+     * Initialize the underlying Connection via the DriverManager.
+     */
+    public void initConnection() throws SQLException {
+        if (getUrl() == null) {
+            throw new IllegalStateException("'url' property is required for lazily initializing a Connection");
+        }
+        synchronized (this.connectionMonitor) {
+            closeConnection();
+            this.target = getConnectionFromDriver(getUsername(), getPassword());
+            prepareConnection(this.target);
+            this.connection = (isSuppressClose() ? getCloseSuppressingConnectionProxy(this.target) : this.target);
+        }
+    }
+
+    /**
+     * Reset the underlying shared Connection, to be reinitialized on next access.
+     */
+    public void resetConnection() {
+        synchronized (this.connectionMonitor) {
+            closeConnection();
+            this.target = null;
+            this.connection = null;
+        }
+    }
+
+    /**
+     * Prepare the given Connection before it is exposed.
+     * <p>The default implementation applies the auto-commit flag, if necessary.
+     * Can be overridden in subclasses.
+     *
+     * @param con the Connection to prepare
+     * @see #setAutoCommit
+     */
+    protected void prepareConnection(Connection con) throws SQLException {
+        Boolean autoCommit = getAutoCommitValue();
+        if (autoCommit != null && con.getAutoCommit() != autoCommit) {
+            con.setAutoCommit(autoCommit);
+        }
+    }
+
+    /**
+     * Close the underlying shared Connection.
+     */
+    private void closeConnection() {
+        if (this.target != null) {
+            try {
+                this.target.close();
+            }
+            catch (Throwable ex) {
+                //logger.warn("Could not close shared JDBC Connection", ex);
+            }
+        }
+    }
+
+    /**
+     * Wrap the given Connection with a proxy that delegates every method call to it
+     * but suppresses close calls.
+     *
+     * @param target the original Connection to wrap
+     * @return the wrapped Connection
+     */
+    protected Connection getCloseSuppressingConnectionProxy(Connection target) {
+        return (Connection) Proxy.newProxyInstance(
+                ConnectionProxy.class.getClassLoader(),
+                new Class[]{ConnectionProxy.class},
+                new CloseSuppressingInvocationHandler(target));
+    }
+
+
+    /**
+     * Invocation handler that suppresses close calls on JDBC Connections.
+     */
+    private static class CloseSuppressingInvocationHandler implements InvocationHandler {
+
+        private final Connection target;
+
+        public CloseSuppressingInvocationHandler(Connection target) {
+            this.target = target;
+        }
+
+        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+            // Invocation on ConnectionProxy interface coming in...
+
+            if (method.getName().equals("equals")) {
+                // Only consider equal when proxies are identical.
+                return (proxy == args[0]);
+            }
+            else if (method.getName().equals("hashCode")) {
+                // Use hashCode of Connection proxy.
+                return System.identityHashCode(proxy);
+            }
+            else if (method.getName().equals("unwrap")) {
+                if (((Class) args[0]).isInstance(proxy)) {
+                    return proxy;
+                }
+            }
+            else if (method.getName().equals("isWrapperFor")) {
+                if (((Class) args[0]).isInstance(proxy)) {
+                    return true;
+                }
+            }
+            else if (method.getName().equals("close")) {
+                // Handle close method: don't pass the call on.
+                return null;
+            }
+            else if (method.getName().equals("isClosed")) {
+                return false;
+            }
+            else if (method.getName().equals("getTargetConnection")) {
+                // Handle getTargetConnection method: return underlying Connection.
+                return this.target;
+            }
+
+            // Invoke method on target Connection.
+            try {
+                return method.invoke(this.target, args);
+            }
+            catch (InvocationTargetException ex) {
+                throw ex.getTargetException();
+            }
+        }
+    }
+
+}

+ 10 - 0
src/main/java/org/elasticsearch/jdbc/SmartDataSource.java

@@ -0,0 +1,10 @@
+package org.elasticsearch.jdbc;
+
+
+import javax.sql.DataSource;
+import java.sql.Connection;
+
+
+public interface SmartDataSource extends DataSource {
+    boolean shouldClose(Connection con);
+}

+ 30 - 0
src/test/java/org/elasticsearch/jdbc/ElasticDriverTest.java

@@ -0,0 +1,30 @@
+package org.elasticsearch.jdbc;
+
+
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.util.Enumeration;
+
+public class ElasticDriverTest {
+    @Test
+    public void testLoadDriver() throws Exception {
+        Class.forName("org.elasticsearch.jdbc.ElasticDriver");
+
+        Enumeration<Driver> driverEnumeration = DriverManager.getDrivers();
+
+        while (driverEnumeration.hasMoreElements()) {
+            Driver driver = driverEnumeration.nextElement();
+            System.out.println(driver.toString());
+        }
+    }
+
+    @Test
+    public void testGetConnection() throws Exception {
+        Class.forName("org.elasticsearch.jdbc.ElasticDriver");
+        Connection connection = DriverManager.getConnection("jdbc:elastic:192.168.0.1:9200");
+        org.junit.Assert.assertTrue(connection instanceof ElasticConnection);
+    }
+}

+ 1 - 1
src/test/java/org/elasticsearch/SqlParserLimitTest.java

@@ -1,4 +1,4 @@
-package org.elasticsearch;
+package org.elasticsearch.query;
 
 import org.elasticsearch.dsl.bean.ElasticSqlParseResult;
 import org.elasticsearch.dsl.parser.ElasticSql2DslParser;

+ 1 - 1
src/test/java/org/elasticsearch/SqlParserListenerTest.java

@@ -1,4 +1,4 @@
-package org.elasticsearch;
+package org.elasticsearch.query;
 
 import org.elasticsearch.dsl.bean.ElasticSqlParseResult;
 import org.elasticsearch.dsl.bean.ElasticSqlQueryField;

+ 1 - 1
src/test/java/org/elasticsearch/SqlParserOrderByTest.java

@@ -1,4 +1,4 @@
-package org.elasticsearch;
+package org.elasticsearch.query;
 
 import org.elasticsearch.dsl.bean.ElasticSqlParseResult;
 import org.elasticsearch.dsl.parser.ElasticSql2DslParser;

+ 1 - 1
src/test/java/org/elasticsearch/SqlParserQueryTest.java

@@ -1,4 +1,4 @@
-package org.elasticsearch;
+package org.elasticsearch.query;
 
 import org.elasticsearch.dsl.bean.ElasticSqlParseResult;
 import org.elasticsearch.dsl.parser.ElasticSql2DslParser;

+ 1 - 1
src/test/java/org/elasticsearch/SqlParserRoutingTest.java

@@ -1,4 +1,4 @@
-package org.elasticsearch;
+package org.elasticsearch.query;
 
 import org.elasticsearch.dsl.bean.ElasticSqlParseResult;
 import org.elasticsearch.dsl.parser.ElasticSql2DslParser;

+ 1 - 1
src/test/java/org/elasticsearch/SqlParserSelectFieldTest.java

@@ -1,4 +1,4 @@
-package org.elasticsearch;
+package org.elasticsearch.query;
 
 import org.apache.commons.collections.CollectionUtils;
 import org.elasticsearch.dsl.bean.ElasticSqlParseResult;

+ 1 - 1
src/test/java/org/elasticsearch/SqlParserWhereConditionTest.java

@@ -1,4 +1,4 @@
-package org.elasticsearch;
+package org.elasticsearch.query;
 
 import org.elasticsearch.action.search.SearchAction;
 import org.elasticsearch.action.search.SearchRequestBuilder;