<commit_before>'use strict';

const ColumnsAnalyser = require('./ColumnsAnalyser');
const Sorter = require('./stream/Sorter');
const Filter = require('./stream/Filter');
const Joiner = require('./stream/Joiner');
const PropertiesPickerTransformer = require('./stream/PropertiesPickerTransformer');
const Groupper = require('./stream/Groupper');
const Order = require('./Order');
const Terminator = require('./stream/Terminator');
const Join = require('./Join');
const Mutator = require('./stream/Mutator');
const Aggregation = require('./Aggregation');
const AggregationExpression = require('./AggregationExpression');
const JlTransformsChain = require('./stream/JlTransformsChain');
const DataRow = require('./DataRow');
const DataSource = require('./DataSource');
const Nodes = require('./sql/Nodes');
const ExpressionAnalyser = require('./ExpressionAnalyser');

const SqlNotSupported = require('./error/SqlNotSupported');
const SqlLogicError = require('./error/SqlLogicError');
const NotSupported = require('./error/NotSupported');
const DataSourceNotFound = require('./error/DataSourceNotFound');

class Select
{
	/**
	 *
	 * @param {PreparingContext} preparingContext
	 * @param {RuntimeContext} runtimeContext
	 * @param {Node} ast
	 */
	constructor(preparingContext, runtimeContext, ast)
	{
		if (ast.table) {
			throw new SqlNotSupported('FROM is not supported yet');
		}

		if (ast.limit) {
			throw new SqlNotSupported('LIMIT is not supported yet');
		}

		/**
		 * @type {PreparingContext}
		 */
		this.preparingContext = preparingContext;

		this.expressionAnalyser = new ExpressionAnalyser(this.preparingContext);

		/**
		 * @type {PreparingContext}
		 */
		this.runtimeContext = runtimeContext;
		this.sqlToJs = preparingContext.sqlToJs;
		this.ast = ast;

		const columnsAnalyser = new ColumnsAnalyser(preparingContext);

		this.columns = columnsAnalyser.analyseColumns(ast.columns);
<commit_msg>Forbid aggregation calls in WHERE<commit_after>'use strict';

const ColumnsAnalyser = require('./ColumnsAnalyser');
const Sorter = require('./stream/Sorter');
const Filter = require('./stream/Filter');
const Joiner = require('./stream/Joiner');
const PropertiesPickerTransformer = require('./stream/PropertiesPickerTransformer');
const Groupper = require('./stream/Groupper');
const Order = require('./Order');
const Terminator = require('./stream/Terminator');
const Join = require('./Join');
const Mutator = require('./stream/Mutator');
const Aggregation = require('./Aggregation');
const AggregationExpression = require('./AggregationExpression');
const JlTransformsChain = require('./stream/JlTransformsChain');
const DataRow = require('./DataRow');
const DataSource = require('./DataSource');
const Nodes = require('./sql/Nodes');
const ExpressionAnalyser = require('./ExpressionAnalyser');

const SqlNotSupported = require('./error/SqlNotSupported');
const SqlLogicError = require('./error/SqlLogicError');
const NotSupported = require('./error/NotSupported');
const DataSourceNotFound = require('./error/DataSourceNotFound');

class Select
{
	/**
	 *
	 * @param {PreparingContext} preparingContext
	 * @param {RuntimeContext} runtimeContext
	 * @param {Node} ast
	 */
	constructor(preparingContext, runtimeContext, ast)
	{
		if (ast.table) {
			throw new SqlNotSupported('FROM is not supported yet');
		}

		if (ast.limit) {
			throw new SqlNotSupported('LIMIT is not supported yet');
		}

		/**
		 * @type {PreparingContext}
		 */
		this.preparingContext = preparingContext;

		this.expressionAnalyser = new ExpressionAnalyser(this.preparingContext);

		/**
		 * @type {PreparingContext}
		 */
		this.runtimeContext = runtimeContext;
		this.sqlToJs = preparingContext.sqlToJs;
		this.ast = ast;

		const columnsAnalyser = new ColumnsAnalyser(preparingContext);

		this.columns = columnsAnalyser.analyseColumns(ast.columns);

		if (this.ast.where && columnsAnalyser.expressionAnalyser.isAggregationExpression(this.ast.where)) {
			throw new SqlLogicError('aggregation function in WHERE');
		}

{'fraction_non_alphanumeric': 0.1438185443668993, 'fraction_numerical': 0.0, 'mean_word_length': 5.2998430141287285, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5952926', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1083, 'n_words': 249}