hints.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "lexer.h"
  3. #include <yql/essentials/public/issue/yql_issue.h>
  4. #include <util/generic/string.h>
  5. #include <util/generic/vector.h>
  6. #include <util/generic/map.h>
  7. #include <util/stream/output.h>
  8. namespace NSQLTranslation {
  9. struct TSQLHint {
  10. // SQL Hints are placed inside comments and have following format:
  11. // /*+ Name('Val''ue1' Value2 Value3) ... Name2(Value1 Value2 Value3) */
  12. // or the same with single line comments:
  13. // --+ Name(Value1 Value2 Value3) ... Name2(Value1 Value2 Value3)
  14. TString Name;
  15. TVector<TString> Values;
  16. NYql::TPosition Pos;
  17. TString ToString() const;
  18. void Out(IOutputStream& o) const;
  19. };
  20. using TSQLHints = TMap<NYql::TPosition, TVector<TSQLHint>>;
  21. // SQL hints are collected by lexer and bound to the position of nearest non-comment token to the left
  22. // For example: SELECT /*+ Name(Value) */ -- Name2(Value2)
  23. // in this case TSQLHints will consist of single entry with position of SELECT token
  24. bool CollectSqlHints(ILexer& lexer, const TString& query, const TString& queryName,
  25. const TString& queryFile, TSQLHints& hints, NYql::TIssues& issues, size_t maxErrors, bool utf8Aware);
  26. }
  27. Y_DECLARE_OUT_SPEC(inline, NSQLTranslation::TSQLHint, stream, value) {
  28. value.Out(stream);
  29. }