File: bigquery-grammar.ym

package info (click to toggle)
syslog-ng 4.8.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,456 kB
  • sloc: ansic: 177,631; python: 13,035; cpp: 11,611; makefile: 7,012; sh: 5,147; java: 3,651; xml: 3,344; yacc: 1,377; lex: 599; perl: 193; awk: 190; objc: 162
file content (167 lines) | stat: -rw-r--r-- 4,713 bytes parent folder | download | duplicates (2)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
 * Copyright (c) 2024 Axoflow
 * Copyright (c) 2024 Attila Szakacs <attila.szakacs@axoflow.com>
 * Copyright (c) 2023 László Várady
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 as published
 * by the Free Software Foundation, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * As an additional exemption you are allowed to compile & link against the
 * OpenSSL libraries as published by the OpenSSL project. See the file
 * COPYING for details.
 *
 */

%code top {
#include "bigquery-parser.h"

}


%code {

#include "cfg-grammar-internal.h"
#include "plugin.h"
#include "syslog-names.h"

#include "bigquery-dest.h"

#include <stdlib.h>

}

%define api.prefix {bigquery_}

%lex-param {CfgLexer *lexer}
%parse-param {CfgLexer *lexer}
%parse-param {LogDriver **instance}
%parse-param {gpointer arg}

/* INCLUDE_DECLS */

%token KW_BIGQUERY
%token KW_URL
%token KW_PROJECT
%token KW_DATASET
%token KW_TABLE
%token KW_SCHEMA
%token KW_PROTOBUF_SCHEMA
%token KW_BATCH_BYTES
%token KW_COMPRESSION

%token KW_KEEP_ALIVE
%token KW_TIME
%token KW_TIMEOUT
%token KW_MAX_PINGS_WITHOUT_DATA

%token KW_CHANNEL_ARGS
%token KW_HEADERS

%type <ptr> bigquery_dest

%%

start
  : LL_CONTEXT_DESTINATION bigquery_dest { YYACCEPT; }
  ;

bigquery_dest
  : KW_BIGQUERY
    {
      last_driver = *instance = bigquery_dd_new(configuration);
    }
    '(' _inner_dest_context_push bigquery_dest_options _inner_dest_context_pop ')' { $$ = last_driver; }
  ;

bigquery_dest_options
  : bigquery_dest_option bigquery_dest_options
  |
  ;

bigquery_dest_option
  : KW_URL '(' string ')' { bigquery_dd_set_url(last_driver, $3); free($3); }
  | KW_PROJECT '(' string ')' { bigquery_dd_set_project(last_driver, $3); free($3); }
  | KW_DATASET '(' string ')' { bigquery_dd_set_dataset(last_driver, $3); free($3); }
  | KW_TABLE '(' string ')' { bigquery_dd_set_table(last_driver, $3); free($3); }
  | KW_SCHEMA '(' bigquery_schema_fields ')'
  | KW_PROTOBUF_SCHEMA '(' path_check LL_ARROW template_content_list ')'
    {
      bigquery_dd_set_protobuf_schema(last_driver, $3, $5);
      free($3);
    }
  | KW_BATCH_BYTES '(' positive_integer ')'
    {
      CHECK_ERROR($3 <= (10 * 1000 * 1000), @3, "batch-bytes() cannot be larger than 10 MB. For more info see https://cloud.google.com/bigquery/quotas#write-api-limits");
      bigquery_dd_set_batch_bytes(last_driver, $3);
    }
  | KW_COMPRESSION '(' yesno ')'
    {
      bigquery_dd_set_compression(last_driver, $3);
    }
  | KW_KEEP_ALIVE '(' bigquery_keepalive_options ')'
  | KW_CHANNEL_ARGS '(' bigquery_dest_channel_args ')'
  | KW_HEADERS '(' bigquery_dest_headers ')'
  | threaded_dest_driver_general_option
  | threaded_dest_driver_workers_option
  | threaded_dest_driver_batch_option
  | { last_template_options = bigquery_dd_get_template_options(last_driver); } template_option
  ;

bigquery_schema_fields
  : bigquery_schema_field bigquery_schema_fields
  |
  ;

bigquery_schema_field
  : string optional_string LL_ARROW template_content
    {
	    CHECK_ERROR(bigquery_dd_add_field(last_driver, $1, $2, $4), @2, "Error adding schema() field, invalid type");
      free($1);
      free($2);
      log_template_unref($4);
    }
  ;

bigquery_keepalive_options
  : bigquery_keepalive_option bigquery_keepalive_options
  |
  ;

bigquery_keepalive_option
  : KW_TIME '(' nonnegative_integer ')' { bigquery_dd_set_keepalive_time(last_driver, $3); }
  | KW_TIMEOUT '(' nonnegative_integer ')' { bigquery_dd_set_keepalive_timeout(last_driver, $3); }
  | KW_MAX_PINGS_WITHOUT_DATA '(' nonnegative_integer ')' { bigquery_dd_set_keepalive_max_pings(last_driver, $3); }
  ;

bigquery_dest_channel_args
  : bigquery_dest_channel_arg bigquery_dest_channel_args
  |
  ;

bigquery_dest_channel_arg
  : string LL_ARROW LL_NUMBER { bigquery_dd_add_int_channel_arg(last_driver, $1, $3); free($1); }
  | string LL_ARROW string { bigquery_dd_add_string_channel_arg(last_driver, $1, $3); free($1); free($3); }
  ;

bigquery_dest_headers
  : bigquery_dest_header bigquery_dest_headers
  |
  ;

bigquery_dest_header
  : string LL_ARROW string { bigquery_dd_add_header(last_driver, $1, $3); free($1); free($3); }
  ;

/* INCLUDE_RULES */

%%