aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/sql_values.h
blob: 7e19d1d8a0d4841e3b7b51a21522b75a2d691c5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include "sql_translation.h"
#include <yql/essentials/parser/proto_ast/gen/v1_proto_split/SQLv1Parser.pb.main.h>

namespace NSQLTranslationV1 {

using namespace NSQLv1Generated;

class TSqlValues: public TSqlTranslation {
public:
    TSqlValues(TContext& ctx, NSQLTranslation::ESqlMode mode)
        : TSqlTranslation(ctx, mode)
    {
    }

    TSourcePtr Build(const TRule_values_stmt& node, TPosition& valuesPos, const TVector<TString>& derivedColumns = {}, TPosition derivedColumnsPos = TPosition());
protected:
    bool BuildRows(const TRule_values_source_row_list& node, TVector<TVector<TNodePtr>>& rows);

    TSourcePtr ValuesSource(const TRule_values_source& node, const TVector<TString>& columnsHint,
        const TString& operationName);

private:
    bool BuildRow(const TRule_values_source_row& inRow, TVector<TNodePtr>& outRow);
};

class TSqlIntoValues: public TSqlValues {
public:
    TSqlIntoValues(TContext& ctx, NSQLTranslation::ESqlMode mode)
        : TSqlValues(ctx, mode)
    {
    }

    TSourcePtr Build(const TRule_into_values_source& node, const TString& operationName);
};

class TSqlAsValues: public TSqlValues {
public:
    TSqlAsValues(TContext& ctx, NSQLTranslation::ESqlMode mode)
        : TSqlValues(ctx, mode)
    {
    }

    TSourcePtr Build(const TRule_values_source& node, const TString& operationName);
};

} // namespace NSQLTranslationV1