Ejemplo n.º 1
0
Archivo: client.py Proyecto: gridl/ibis
    def version(self):
        self.con.connection.force_connect()

        try:
            server = self.con.connection.server_info
            vstring = '{}.{}.{}'.format(server.version_major,
                                        server.version_minor, server.revision)
        except Exception:
            self.con.connection.disconnect()
            raise
        else:
            return parse_version(vstring)
Ejemplo n.º 2
0
    def connect(self, data_directory):
        user = os.environ.get('IBIS_TEST_MYSQL_USER', 'ibis')
        password = os.environ.get('IBIS_TEST_MYSQL_PASSWORD', 'ibis')
        host = os.environ.get('IBIS_TEST_MYSQL_HOST', 'localhost')
        database = os.environ.get('IBIS_TEST_MYSQL_DATABASE', 'ibis_testing')
        con = ibis.mysql.connect(host=host, user=user, password=password,
                                 database=database)

        # mariadb supports window operations after version 10.2
        # but the sqlalchemy version string looks like:
        # 5.5.5.10.2.12.MariaDB.10.2.12+maria~jessie
        if 'MariaDB' in str(con.version):
            # we might move this parsing step to the mysql client
            version = tuple(map(int, str(con.version).split('.')[7:9]))
            if version >= (10, 2):
                self.supports_window_operations = True
        elif con.version >= parse_version('8.0'):
            # mysql supports window operations after version 8
            self.supports_window_operations = True

        return con
Ejemplo n.º 3
0
 def version(self):
     return parse_version(pa.__version__)
Ejemplo n.º 4
0
def test_version(backend, con):
    expected_type = (type(parse_version('1.0')),
                     type(parse_version('1.0-legacy')))
    assert isinstance(con.version, expected_type)
Ejemplo n.º 5
0
 def version(self):
     vstring = '.'.join(map(str, self.con.dialect.server_version_info))
     return parse_version(vstring)
Ejemplo n.º 6
0
 def version(self):
     return parse_version(pymapd.__version__)
Ejemplo n.º 7
0

@pytest.mark.skipif(not PY2, reason="testing for PY2")
def test_times_ops_py2(t, df):
    with pytest.raises(ValueError):
        t.plain_datetimes_naive.time()


@pytest.mark.parametrize(('op', 'expected'), [
    param(lambda x, y: x + y, lambda x, y: x.values * 2, id='add'),
    param(lambda x, y: x * 2, lambda x, y: x.values * 2, id='mul'),
    param(lambda x, y: x // 2,
          lambda x, y: x.values // 2,
          id='floordiv',
          marks=pytest.mark.xfail(
              parse_version(pd.__version__) < parse_version('0.23.0'),
              raises=TypeError,
              reason=('pandas versions less than 0.23.0 do not support floor '
                      'division involving timedelta columns'))),
])
def test_interval_arithmetic(op, expected):
    data = pd.timedelta_range('0 days', '10 days', freq='D')
    con = ibis.pandas.connect({
        'df1': pd.DataFrame({'td': data}),
        'df2': pd.DataFrame({'td': data}),
    })
    t1 = con.table('df1')
    expr = op(t1.td, t1.td)
    result = expr.execute()
    expected = pd.Series(expected(data, data), name='td')
    tm.assert_series_equal(result, expected)