aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/sql/v1/format/sql_format.h
blob: 6944a730710caa6d4778a14f7487d5587eda5f7a (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
#pragma once

#include <yql/essentials/public/issue/yql_issue.h>
#include <yql/essentials/sql/settings/translation_settings.h>

#include <util/generic/string.h>

namespace NSQLFormat {

constexpr ui32 OneIndent = 4;

enum class EFormatMode {
    Pretty,
    Obfuscate
};

class ISqlFormatter {
public:
    using TPtr = THolder<ISqlFormatter>;

    virtual bool Format(const TString& query, TString& formattedQuery, NYql::TIssues& issues,
        EFormatMode mode = EFormatMode::Pretty) = 0;
    virtual ~ISqlFormatter() = default;
};

ISqlFormatter::TPtr MakeSqlFormatter(const NSQLTranslation::TTranslationSettings& settings = {});

// insert spaces and comments between each tokens
TString MutateQuery(const TString& query, const NSQLTranslation::TTranslationSettings& settings = {});

bool SqlFormatSimple(const TString& query, TString& formattedQuery, TString& error);

THashSet<TString> GetKeywords();

}