UNPKG

@uwdata/mosaic-sql

Version:

SQL query construction and analysis.

38 lines 1.32 kB
import { SAMPLE_CLAUSE } from '../constants.js'; import { SQLNode } from './node.js'; export class SampleClauseNode extends SQLNode { /** The sample size as either a row count or percentage. */ size; /** Flag if the sampling unit is rows (`false`) or percentage (`true`). */ perc; /** The sampling method. */ method; /** The random seed. */ seed; /** * Instantiate a sample clause node. * @param size The sample size as either a row count or percentage. * @param perc Flag indicating if the sampling unit is * rows (`false`) or a percentage (`true`). * @param method The sampling method. If unspecified, * a default method is applied based on the sampling unit. * @param seed The random seed. */ constructor(size, perc = false, method, seed) { super(SAMPLE_CLAUSE); this.size = size; this.perc = perc; this.method = method; this.seed = seed; } /** * Generate a SQL query string for this node. */ toString() { const { size, perc, method, seed } = this; const m = method ? `${method} ` : ''; const s = seed != null ? ` REPEATABLE (${seed})` : ''; return `${m}(${size}${perc ? '%' : ' ROWS'})${s}`; } } //# sourceMappingURL=sample.js.map