--- /dev/null
+.. change::
+ :tags: bug, sql, regression
+ :tickets: 6735
+
+ Fixed regression where the :func:`_sql.tablesample` construct would fail to
+ be executable when constructed given a floating-point sampling value not
+ embedded within a SQL function.
sampling, name=name, seed=seed
)
+ @util.preload_module("sqlalchemy.sql.functions")
def _init(self, selectable, sampling, name=None, seed=None):
+ functions = util.preloaded.sql_functions
+ if not isinstance(sampling, functions.Function):
+ sampling = functions.func.system(sampling)
+
self.sampling = sampling
self.seed = seed
super(TableSample, self)._init(selectable, name=name)
- @util.preload_module("sqlalchemy.sql.functions")
def _get_method(self):
- functions = util.preloaded.sql_functions
- if isinstance(self.sampling, functions.Function):
- return self.sampling
- else:
- return functions.func.system(self.sampling)
+ return self.sampling
class CTE(
.union_all(select(table_a.c.b)),
select(table_a.c.a).lateral(),
select(table_a.c.a).lateral(name="bar"),
+ table_a.tablesample(0.75),
table_a.tablesample(func.bernoulli(1)),
table_a.tablesample(func.bernoulli(1), seed=func.random()),
table_a.tablesample(func.bernoulli(1), seed=func.other_random()),