{"id":313,"date":"2021-04-06T09:43:15","date_gmt":"2021-04-06T07:43:15","guid":{"rendered":"https:\/\/stage.usercentrics.com\/?post_type=knowledge&p=8263"},"modified":"2024-09-03T19:39:19","modified_gmt":"2024-09-03T17:39:19","slug":"working-with-data-in-bigquery-using-node-js","status":"publish","type":"knowledge","link":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/","title":{"rendered":"Working with data in BigQuery using Node.js"},"content":{"rendered":"\n\n<h2 class=\"wp-block-heading\">BigQuery Terms<\/h2>\n<p><span style=\"font-weight: 400;\">Before starting with any implementation, some basic terms used in BigQuery, need to be clarified.<\/span><\/p>\n<p><b>Datasets<\/b><\/p>\n<p><span style=\"font-weight: 400;\">In BigQuery, you have entities called <\/span><i><span style=\"font-weight: 400;\">datasets<\/span><\/i><span style=\"font-weight: 400;\">. A dataset is nothing more than a container on the top-level of your project used to organize and control access to your tables and views. Thus, a table has to have a dataset it belongs to, so before building your first table, you first have to create a dataset.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">When getting started, it&#8217;s OK to see datasets as a simple grouping mechanism, even though under the hood, it is, of course, a bit more.<\/span><\/p>\n<p><b>Tables and table schemas<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Google BigQuery is a relational database and uses a table structure to organize individual records in rows, while each record consists of columns that are also called <\/span><i><span style=\"font-weight: 400;\">fields<\/span><\/i><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Also, typical for RDBMS, Google defines BigQuery tables by a table schema composed of the columns and their definition. A table&#8217;s schema can either be applied at table creation or auto-detected by BigQuery when the first set of data populates the table, even though I would always recommend defining the schema before-hand.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">If you have experience using SQL-based RDBMS, you will quickly get into BigQuery.<\/span><\/p>\n<p><b>Columns<\/b><\/p>\n<p><span style=\"font-weight: 400;\">BigQuery defines the columns\/fields of a table schema via four different properties.<\/span><\/p>\n<p><b>Column name<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The column name has to be a case-insensitive alphanumerical string with a maximum of 128 characters. Underscores are also allowed, and the name has to start with either a letter or underscore.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Even though there are three names columns are not allowed to have:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">_TABLE_<\/span><\/i><\/li>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">_FILE_<\/span><\/i><\/li>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">_PARTITION<\/span><\/i><\/li>\n<\/ul>\n<p><b>Column description<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The column description is an optional string describing the column with a maximum of 1,024 characters.<\/span><\/p>\n<p><b>Type<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The type is a mandatory field describing the data type of the column. Possible values are, e.g.:\u00a0<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">INT64\u00a0<\/span><\/i><\/li>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">FLOAT64<\/span><\/i><\/li>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">BOOL<\/span><\/i><\/li>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">STRING<\/span><\/i><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">You can find a list of all possible values in the <\/span><a href=\"https:\/\/cloud.google.com\/bigquery\/docs\/schemas#standard_sql_data_types\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">official BigQuery docs<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><b>Modes<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Each column also can have a so-called optional mode. The mode of a column can be one of three possible values.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">Nullable<\/span><\/i><span style=\"font-weight: 400;\"> \u2014 <\/span><i><span style=\"font-weight: 400;\">NULL<\/span><\/i><span style=\"font-weight: 400;\"> values are allowed (default)<\/span><\/li>\n<li style=\"font-weight: 400;\"><i><span style=\"font-weight: 400;\">Required<\/span><\/i><span style=\"font-weight: 400;\"> \u2014 <\/span><i><span style=\"font-weight: 400;\">NULL<\/span><\/i><span style=\"font-weight: 400;\"> values are not allowed<\/span><\/li>\n<\/ul>\n<p><i><span style=\"font-weight: 400;\">Repeated<\/span><\/i><span style=\"font-weight: 400;\"> \u2014 The field contains an array of values of the specified data type instead of a single value.<\/span><\/p>\n<p>&nbsp;<\/p>\n\n\n<h2 class=\"wp-block-heading\">Hands-on BigQuery<\/h2>\n<p><span style=\"font-weight: 400;\">After defining the absolute basics one should know before getting started with BigQuery, we will now set up a small BigQuery project using Node.js. <\/span><span style=\"font-weight: 400;\">Since this is an article using Node.js, I expect that Node.js and NPM are available on the readers&#8217; machine.<\/span><\/p>\n<p><b>Setup of a clean Node.js project using BigQuery<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">First, we have to create a new NPM module using npm init.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Second, we have to install the BigQuery NPM module using npm i &#8211;save @google-cloud\/bigquery.\u00a0<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Finally, we need to create a new JavaScript file to put our code into \u2192 touch index.js.<\/span><\/li>\n<\/ul>\n<p><b>GCP service account<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Regardless of application size, I always recommend creating an extra service account via GCP IAM to ensure security and correct permissions are in place, regardless of who runs the application. How to create an additional service account in detail is outside the scope of this article but can be simplified in a few easy steps:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">On GCP: Go to &#8220;IAM &#038; Admin&#8221; \u2192 Service Accounts \u2192 Create Service Account<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Create a new account and select the appropriate role, e.g., for this article: BigQuery Data Editor + BigQuery User<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Select the created service account \u2192 Keys \u2192 Add Key \u2192 Create New Key \u2192 Key Type JSON \u2192 Download the key<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Make sure to add the key file to your just created Node.js project. Just be aware that you should never commit these critical files to Git! If you want to know how to store your secrets in Git securely, <\/span><a href=\"https:\/\/levelup.gitconnected.com\/securing-your-secrets-in-git-the-safe-way-using-gcp-kms-ada49e8386af\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">you can check out one of my other articles on medium<\/span><\/a><span style=\"font-weight: 400;\">:<\/span><\/p>\n<p><b>Creating datasets and tables via code<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Now let&#8217;s get to the actual code and create a dataset, a table, and a schema to insert our data.<\/span><\/p>\n<p><b><a href=\"https:\/\/gist.github.com\/mr-pascal\/b1d85a4ca7b72710b982a91404d92e00\" target=\"_blank\" rel=\"noopener\">bigquery create dataset table<\/a>\u00a0<\/b><\/p>\n<div id=\"attachment_9081\" style=\"width: 974px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-9081\" class=\"wp-image-9081 size-full\" src=\"https:\/\/usercentrics.com\/wp-content\/uploads\/sites\/7\/2021\/05\/CODE_SNIPPET_CREATE_DATASET_TABLE.png\" alt=\"bigquery create dataset table\" width=\"964\" height=\"1282\" \/><p id=\"caption-attachment-9081\" class=\"wp-caption-text\">bigquery create dataset table<\/p><\/div>\n<p><span style=\"font-weight: 400;\">Even though the above script should be straightforward, let&#8217;s go quickly over it:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">First, create a new BigQuery client. Make sure to replace its parameter values with your specific ones. e.g., your GCP project should be something different than mine.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Second, construct a simple wrapper method for creating a new dataset on BigQuery, taking a dataset name as an input parameter and returning the created dataset&#8217;s ID.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Third, creating a new table by its name and the dataset ID, the table should be attached to and returning the table ID.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Afterward, we define the <\/span><i><span style=\"font-weight: 400;\">main<\/span><\/i><span style=\"font-weight: 400;\"> method that bundles together the create dataset and table method calls.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">When you run the script, the program should print out the following to the console:<\/span><\/p>\n<ul>\n<li><i><span style=\"font-weight: 400;\">Dataset &#8216;my_test_dataset&#8217; created.<\/span><\/i><\/li>\n<li><i><span style=\"font-weight: 400;\">Table &#8216;my_test_table&#8217; created.<\/span><\/i><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">You should also verify the result by checking BigQuery in the GCP console. As you can see in the following image, the application created the dataset and table with the above schema in the demo project silicon-alpha-307608.<\/span><\/p>\n<div id=\"attachment_8262\" style=\"width: 1033px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8262\" class=\"wp-image-8262 size-full\" src=\"https:\/\/usercentrics.com\/wp-content\/uploads\/sites\/7\/2021\/04\/GCP_BIGQUERY.png\" alt=\"GCP_BIGQUERY\" width=\"1023\" height=\"420\" \/><p id=\"caption-attachment-8262\" class=\"wp-caption-text\">GCP_BIGQUERY<\/p><\/div>\n<p>&nbsp;<\/p>\n\n\n<div class=\"uc-notice\">\n    <div class=\"uc-notice__icon\">\n        <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n<path d=\"M11.8177 17.0093C12.1011 17.0093 12.3386 16.9134 12.5302 16.7218C12.7219 16.5301 12.8177 16.2926 12.8177 16.0093C12.8177 15.7259 12.7219 15.4884 12.5302 15.2968C12.3386 15.1051 12.1011 15.0093 11.8177 15.0093C11.5344 15.0093 11.2969 15.1051 11.1052 15.2968C10.9136 15.4884 10.8177 15.7259 10.8177 16.0093C10.8177 16.2926 10.9136 16.5301 11.1052 16.7218C11.2969 16.9134 11.5344 17.0093 11.8177 17.0093ZM10.8177 13.0093H12.8177V7.00928H10.8177V13.0093ZM11.8177 22.0093C10.4344 22.0093 9.13442 21.7468 7.91775 21.2218C6.70108 20.6968 5.64275 19.9843 4.74275 19.0843C3.84275 18.1843 3.13025 17.1259 2.60525 15.9093C2.08025 14.6926 1.81775 13.3926 1.81775 12.0093C1.81775 10.6259 2.08025 9.32594 2.60525 8.10928C3.13025 6.89261 3.84275 5.83428 4.74275 4.93428C5.64275 4.03428 6.70108 3.32178 7.91775 2.79678C9.13442 2.27178 10.4344 2.00928 11.8177 2.00928C13.2011 2.00928 14.5011 2.27178 15.7177 2.79678C16.9344 3.32178 17.9928 4.03428 18.8927 4.93428C19.7927 5.83428 20.5052 6.89261 21.0302 8.10928C21.5552 9.32594 21.8177 10.6259 21.8177 12.0093C21.8177 13.3926 21.5552 14.6926 21.0302 15.9093C20.5052 17.1259 19.7927 18.1843 18.8927 19.0843C17.9928 19.9843 16.9344 20.6968 15.7177 21.2218C14.5011 21.7468 13.2011 22.0093 11.8177 22.0093Z\" fill=\"black\"\/>\n<\/svg>\n    <\/div>\n    <div class=\"uc-notice__content\">\n                <p><b>IMPORTANT\ufe0f<\/b><\/p>\n<p><span style=\"font-weight: 400;\">After creating a new table in BigQuery, BigQuery typically takes 1\u20132 minutes for the table to be ready. So it would be best if you don&#8217;t create a table and immediately afterward stream data into it to prevent errors.<\/span><\/p>\n            <\/div>\n<\/div>\n\n\n\n\n<p><b>Streaming data into a BigQuery table<\/b><\/p>\n<p><span style=\"font-weight: 400;\">The streaming of data into a BigQuery table is pretty easy, and you can see an example in the following snippet. You have to make sure that the service account you use owns the &#8220;BigQuery User&#8221; role or something superior otherwise, it will throw an error due to missing permissions.<\/span><\/p>\n<p><b><a href=\"https:\/\/gist.github.com\/mr-pascal\/dbfce542a9ffc875bd7198632a11113c\" target=\"_blank\" rel=\"noopener\">stream rows in bigquery<\/a><\/b><\/p>\n<div id=\"attachment_9088\" style=\"width: 1934px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-9088\" class=\"wp-image-9088 size-full\" src=\"https:\/\/usercentrics.com\/wp-content\/uploads\/sites\/7\/2021\/05\/CODE_SNIPPET_INSERT.png\" alt=\"stream rows in bigquery\" width=\"1924\" height=\"1074\" \/><p id=\"caption-attachment-9088\" class=\"wp-caption-text\">stream rows in bigquery<\/p><\/div>\n<p><span style=\"font-weight: 400;\">Inserting the data into a BigQuery table is as simple as it could get:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">First, define the rows you want to insert. Make sure that the rows are matching the defined table schema. Otherwise, it will throw an error.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Second, tell BigQuery that you want to insert the rows into the table under the corresponding dataset.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">In the case that you try to insert an invalid row, it will throw an error like the one in the following snippet, where it tells says that the field Hello does not exist.<\/span><\/p>\n<p><b><a href=\"https:\/\/gist.github.com\/mr-pascal\/7fad695dfd1a420ee6a6e2e27d246393\" target=\"_blank\" rel=\"noopener\">bigquery insert error<\/a><\/b><\/p>\n<div id=\"attachment_9092\" style=\"width: 1950px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-9092\" class=\"wp-image-9092 size-full\" src=\"https:\/\/usercentrics.com\/wp-content\/uploads\/sites\/7\/2021\/05\/CODE_SNIPPET_INSERT_ERROR.png\" alt=\"bigquery insert error\" width=\"1940\" height=\"1396\" \/><p id=\"caption-attachment-9092\" class=\"wp-caption-text\">bigquery insert error<\/p><\/div>\n<p><b>Query data from BigQuery<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Requesting data from BigQuery is almost as easy as inserting data, even though a bit different. Similar to inserting data, we also need the &#8220;BigQuery User&#8221; role for retrieving data.<\/span><\/p>\n<p><b><a href=\"https:\/\/gist.github.com\/mr-pascal\/d75d98495b96ead6cba4fe3cf3b33573\" target=\"_blank\" rel=\"noopener\">retrieve data from bigquery<\/a><\/b><\/p>\n<div id=\"attachment_9094\" style=\"width: 1946px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-9094\" class=\"wp-image-9094 size-full\" src=\"https:\/\/usercentrics.com\/wp-content\/uploads\/sites\/7\/2021\/05\/CODE_SNIPPET_QUERY_DATA.png\" alt=\"retrieve data from bigquery\" width=\"1936\" height=\"1288\" \/><p id=\"caption-attachment-9094\" class=\"wp-caption-text\">retrieve data from bigquery<\/p><\/div>\n<p><span style=\"font-weight: 400;\">Retrieving data from BigQuery can be summarized in three easy steps:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">First, create the SQL query that defines the selected fields, the number of rows to retrieve, etc.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Second, create and trigger a query job that runs the provided query asynchronously in the background.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Third, take the returned job object from the second step and wait for the query results.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">In the following image, you can see the console output of running the getData() method from above after running the previous insertion script three times before.<\/span><\/p>\n<div id=\"attachment_8261\" style=\"width: 451px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-8261\" class=\"wp-image-8261 size-full\" src=\"https:\/\/usercentrics.com\/wp-content\/uploads\/sites\/7\/2021\/04\/CONSOLE_OUTPUT.png\" alt=\"CONSOLE_OUTPUT\" width=\"441\" height=\"165\" \/><p id=\"caption-attachment-8261\" class=\"wp-caption-text\">CONSOLE_OUTPUT<\/p><\/div>\n<p><span style=\"font-weight: 400;\">Reviewing the above three steps, you might ask, &#8220;Why don&#8217;t I already receive the query results in the second step and have to make an additional request for getting it explicitly?&#8221;. Good question. We will provide the answer for this in the next section.<\/span><\/p>\n\n\n<h2 class=\"wp-block-heading\">BigQuery jobs<\/h2>\n<p><span style=\"font-weight: 400;\">Jobs in BigQuery are similar to jobs in other technologies. In simple terms, jobs are asynchronous actions that are created and afterward scheduled and run automatically by BigQuery.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Queries, in general, needs to be executed via a job. That is because jobs can take a very long time to complete, and you don&#8217;t want to have your application blocked for several hours.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So the usual case for long-running queries is to create the corresponding job and poll it from time to time to check its status. Since inserting data is no long-running job, insertions can run directly without creating a job.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">We awaited the job in the above query because we knew it would not take long. But primarily, when you use BigQuery for BigData analytics and query several TB or PB of data, it should be considered using some non-blocking approach.<\/span><\/p>\n<p><b>BigQuery job status<\/b><\/p>\n<p><span style=\"font-weight: 400;\">A job in BigQuery can be in one of three different states:<\/span><\/p>\n<p><strong>PENDING: <\/strong><span style=\"font-weight: 400;\">The job is scheduled but hasn&#8217;t started yet<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>RUNNING: <\/strong><\/span><span style=\"font-weight: 400;\">The job is currently in progress<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>DONE: <\/strong><\/span><span style=\"font-weight: 400;\">The job has finished. Even though BigQuery reports the <\/span><i><span style=\"font-weight: 400;\">DONE<\/span><\/i><span style=\"font-weight: 400;\"> state as <\/span><i><span style=\"font-weight: 400;\">SUCCESS<\/span><\/i><span style=\"font-weight: 400;\"> or <\/span><i><span style=\"font-weight: 400;\">FAILURE<\/span><\/i><span style=\"font-weight: 400;\">, it depends on possible errors.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Due to the above states, it is, of course, also possible to cancel already running jobs. That is especially useful if you accidentally triggered a long-running job or if a job is taking way longer than expected and you want to stop it to prevent too many costs.<\/span><\/p>\n\n\n<div id=\"uc-cta_69ea8ba5c066b\" class=\"uc-cta uc-cta--illustration uc-cta--primary uc-ctx--blue\">\n    <div class=\"uc-cta__inner container\">\n        <div class=\"uc-cta__content\">\n                            <div class=\"uc-cta__label like-label-m\">Whitepaper<\/div>\n                                        <div class=\"uc-cta__heading no-default-margin\">Marketing is driven by ever-changing technologies and data streams &#8211; ensure your website brings them together seamlessly <\/div>\n                                        <div class=\"uc-cta__description\">\n                    <p>Check out our whitepaper to learn more about strategies to optimize opt-ins while maintaining data compliance. <\/p>\n                <\/div>\n                                                    <div class=\"uc-cta__buttons\">\n                    <a id=\"755771fb-fd8b-4488-b151-9c147c2f089c\" class=\"uc-button uc-button-size-m uc-button-contained  no-default-link-decoration\" href=\"https:\/\/usercentrics.com\/resources\/opt-in-optimization\/\" target=\"\"><span>Read now<\/span><\/a>                <\/div>\n                                            <\/div>\n                            <div class=\"uc-cta__section\">\n                                                                    <div class=\"uc-cta__section__img-wrapper\">\n                                <img loading=\"lazy\" decoding=\"async\" width=\"1\" height=\"1\" src=\"https:\/\/usercentrics.com\/us\/wp-content\/uploads\/sites\/7\/2021\/04\/Checklist.png\" class=\"attachment-large size-large\" alt=\"Icon_Checklist\" \/>                            <\/div>\n                                                            <\/div>\n            <\/div>\n<\/div>\n    <script type=\"module\">\n        new Uc_Cta(document.getElementById(\"uc-cta_69ea8ba5c066b\"));\n    <\/script>\n\n\n<div class=\"uc-notice\">\n    <div class=\"uc-notice__icon\">\n        <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n<path d=\"M11.8177 17.0093C12.1011 17.0093 12.3386 16.9134 12.5302 16.7218C12.7219 16.5301 12.8177 16.2926 12.8177 16.0093C12.8177 15.7259 12.7219 15.4884 12.5302 15.2968C12.3386 15.1051 12.1011 15.0093 11.8177 15.0093C11.5344 15.0093 11.2969 15.1051 11.1052 15.2968C10.9136 15.4884 10.8177 15.7259 10.8177 16.0093C10.8177 16.2926 10.9136 16.5301 11.1052 16.7218C11.2969 16.9134 11.5344 17.0093 11.8177 17.0093ZM10.8177 13.0093H12.8177V7.00928H10.8177V13.0093ZM11.8177 22.0093C10.4344 22.0093 9.13442 21.7468 7.91775 21.2218C6.70108 20.6968 5.64275 19.9843 4.74275 19.0843C3.84275 18.1843 3.13025 17.1259 2.60525 15.9093C2.08025 14.6926 1.81775 13.3926 1.81775 12.0093C1.81775 10.6259 2.08025 9.32594 2.60525 8.10928C3.13025 6.89261 3.84275 5.83428 4.74275 4.93428C5.64275 4.03428 6.70108 3.32178 7.91775 2.79678C9.13442 2.27178 10.4344 2.00928 11.8177 2.00928C13.2011 2.00928 14.5011 2.27178 15.7177 2.79678C16.9344 3.32178 17.9928 4.03428 18.8927 4.93428C19.7927 5.83428 20.5052 6.89261 21.0302 8.10928C21.5552 9.32594 21.8177 10.6259 21.8177 12.0093C21.8177 13.3926 21.5552 14.6926 21.0302 15.9093C20.5052 17.1259 19.7927 18.1843 18.8927 19.0843C17.9928 19.9843 16.9344 20.6968 15.7177 21.2218C14.5011 21.7468 13.2011 22.0093 11.8177 22.0093Z\" fill=\"black\"\/>\n<\/svg>\n    <\/div>\n    <div class=\"uc-notice__content\">\n                <div class=\"like-h4 no-default-margin\">What&#8217;s next?<\/div>\n<p> <span style=\"font-weight: 400;\">In the following articles, we will learn what partitioned tables in BigQuery are and how to use them to improve your table performance and costs.<\/span><\/p>\n            <\/div>\n<\/div>\n\n\n\n\n<h2 class=\"wp-block-heading\">Author<\/h2>\n<p><strong>Pascal Zwikirsch<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">Pascal Zwikirsch is a Technical Team Lead at Usercentrics. He manages a cross-functional team of several frontend and backend developers while providing a seamless connection between the technical world and the product managers and stakeholders.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Pascal was a former frontend developer for several years and now specializes in backend services, cloud architectures, and DevOps principles<\/span><b>.<\/b><span style=\"font-weight: 400;\"> He experienced both worlds in detail.<\/span> <span style=\"font-weight: 400;\">This experience and the collaboration with product managers made him capable of constructing full-fledged scalable software.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Besides his job as a Team Lead of the B2B developer team, he likes to share his in-depth knowledge and insights in articles he creates as an independent technical writer.<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>For more content, follow me on <a href=\"https:\/\/www.linkedin.com\/in\/pascal-zwikirsch-3a95a1177\/\" target=\"_blank\" rel=\"noopener\">LinkedIn<\/a><\/strong><\/span><\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.<\/p>\n","protected":false},"featured_media":2080,"template":"","meta":{"_acf_changed":false,"editor_notices":[],"footnotes":""},"tags":[],"magazine_issue":[],"magazine_tag":[],"resource_tag":[14,13],"class_list":["post-313","knowledge","type-knowledge","status-publish","has-post-thumbnail","hentry","resource_tag-privacy","resource_tag-regulations"],"acf":[],"yoast_head":"<title>Working with data in BigQuery using Node.js<\/title>\n<meta name=\"description\" content=\"This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Working with data in BigQuery using Node.js\" \/>\n<meta property=\"og:description\" content=\"This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/\" \/>\n<meta property=\"og:site_name\" content=\"Usercentrics - US\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/usercentrics\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-03T17:39:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/usercentrics.com\/us\/wp-content\/uploads\/sites\/7\/2021\/03\/Google-BigQuery.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1\" \/>\n\t<meta property=\"og:image:height\" content=\"1\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Working with data in BigQuery using Node.js\" \/>\n<meta name=\"twitter:description\" content=\"This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.\" \/>\n<meta name=\"twitter:site\" content=\"@usercentrics\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/\",\"url\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/\",\"name\":\"Working with data in BigQuery using Node.js\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2021\\\/03\\\/Google-BigQuery.png\",\"datePublished\":\"2021-04-06T07:43:15+00:00\",\"dateModified\":\"2024-09-03T17:39:19+00:00\",\"description\":\"This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/\"}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/#primaryimage\",\"url\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2021\\\/03\\\/Google-BigQuery.png\",\"contentUrl\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2021\\\/03\\\/Google-BigQuery.png\",\"copyrightNotice\":\"\u00a9 Copyright 2026 Usercentrics GmbH\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Usercentrics GmbH\"},\"creditText\":\"Image: Usercentrics GmbH\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Resources\",\"item\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/resources\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Blog\",\"item\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Working with data in BigQuery using Node.js\",\"item\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/knowledge-hub\\\/working-with-data-in-bigquery-using-node-js\\\/\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/#website\",\"url\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/\",\"name\":\"Usercentrics - US\",\"description\":\"Consent Management Platform (CMP) Usercentrics\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/usercentrics.com\\\/us\\\/?s={search_term_string}\"}}],\"inLanguage\":\"en-US\"}]}<\/script>","yoast_head_json":{"title":"Working with data in BigQuery using Node.js","description":"This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.","robots":{"index":"noindex","follow":"follow"},"og_locale":"en_US","og_type":"article","og_title":"Working with data in BigQuery using Node.js","og_description":"This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.","og_url":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/","og_site_name":"Usercentrics - US","article_publisher":"https:\/\/www.facebook.com\/usercentrics","article_modified_time":"2024-09-03T17:39:19+00:00","og_image":[{"url":"https:\/\/usercentrics.com\/us\/wp-content\/uploads\/sites\/7\/2021\/03\/Google-BigQuery.png","width":1,"height":1,"type":"image\/png"}],"twitter_card":"summary_large_image","twitter_title":"Working with data in BigQuery using Node.js","twitter_description":"This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.","twitter_site":"@usercentrics","twitter_misc":{"Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/","url":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/","name":"Working with data in BigQuery using Node.js","isPartOf":{"@id":"https:\/\/usercentrics.com\/us\/#website"},"primaryImageOfPage":{"@id":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/#primaryimage"},"image":{"@id":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/#primaryimage"},"thumbnailUrl":"https:\/\/usercentrics.com\/us\/wp-content\/uploads\/sites\/7\/2021\/03\/Google-BigQuery.png","datePublished":"2021-04-06T07:43:15+00:00","dateModified":"2024-09-03T17:39:19+00:00","description":"This article wants to get a bit into the actual usage of BigQuery and show how to read and write data using Node.js.","breadcrumb":{"@id":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/"}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/#primaryimage","url":"https:\/\/usercentrics.com\/us\/wp-content\/uploads\/sites\/7\/2021\/03\/Google-BigQuery.png","contentUrl":"https:\/\/usercentrics.com\/us\/wp-content\/uploads\/sites\/7\/2021\/03\/Google-BigQuery.png","copyrightNotice":"\u00a9 Copyright 2026 Usercentrics GmbH","creator":{"@type":"Organization","name":"Usercentrics GmbH"},"creditText":"Image: Usercentrics GmbH"},{"@type":"BreadcrumbList","@id":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Resources","item":"https:\/\/usercentrics.com\/us\/resources\/"},{"@type":"ListItem","position":2,"name":"Blog","item":"https:\/\/usercentrics.com\/us\/knowledge-hub\/"},{"@type":"ListItem","position":3,"name":"Working with data in BigQuery using Node.js","item":"https:\/\/usercentrics.com\/us\/knowledge-hub\/working-with-data-in-bigquery-using-node-js\/"}]},{"@type":"WebSite","@id":"https:\/\/usercentrics.com\/us\/#website","url":"https:\/\/usercentrics.com\/us\/","name":"Usercentrics - US","description":"Consent Management Platform (CMP) Usercentrics","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/usercentrics.com\/us\/?s={search_term_string}"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/knowledge\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/knowledge"}],"about":[{"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/types\/knowledge"}],"version-history":[{"count":0,"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/knowledge\/313\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/media\/2080"}],"wp:attachment":[{"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/media?parent=313"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/tags?post=313"},{"taxonomy":"magazine_issue","embeddable":true,"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/magazine_issue?post=313"},{"taxonomy":"magazine_tag","embeddable":true,"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/magazine_tag?post=313"},{"taxonomy":"resource_tag","embeddable":true,"href":"https:\/\/usercentrics.com\/us\/wp-json\/wp\/v2\/resource_tag?post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}