def peek(self, count=10, max_block_size=30000): ctx = Vulkn() sql = self.sql q = f""" SELECT _i AS i, _v AS v FROM ( SELECT _i, _v FROM ({sql}) ARRAY JOIN arrayEnumerate(arraySlice(v, 1, {count})) AS _i, arraySlice(v, 1, {count}) AS _v ) SETTINGS max_block_size={max_block_size}""" return ctx._conn.select(q).to_records()
def _cache(self, engine=None): ctx = Vulkn() engine = engine or vulkn.engines.Memory() return ctx.session.cache(self.sql, engine=engine)
def index_agg(self, agg): ctx = Vulkn() q = 'SELECT {agg}(i) AS {agg} FROM ({vector})' return ctx._conn.select(q.format(agg=agg, vector=self.sql)).to_records()
def peek(self, count=10, max_block_size=30000): ctx = Vulkn() sql = self.sql q = f'SELECT i, v FROM ({sql}) WHERE i <= {count} ORDER BY i LIMIT {count} SETTINGS max_block_size={max_block_size}' return ctx._conn.select(q).to_records()
def exec(self): ctx = Vulkn() return ctx._conn.select(self.sql)
def index_agg(self, agg): ctx = Vulkn() vector = self.sql q = f"SELECT arrayReduce('{agg}', arrayEnumerate(v)) AS v FROM ({vector})" return ctx._conn.select(q).to_records()
def agg(self, agg): ctx = Vulkn() vector = self.sql q = f"SELECT arrayReduce('{agg}', v) AS v FROM ({vector})" return ctx._conn.select(q).to_records()
def _cache(self): ctx = Vulkn() return ctx.session.cache(self.sql, mode=session.CacheMode.Array)