question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[firestore-bigquery-export] gen-schema-view script - Duplicate entries created when using array types in schema

See original GitHub issue
  • Extension name: firestore-bigquery-export
  • Extension version: 0.1.16

Amazing extension, this is exactly what I was looking for.

I’m using the gen-schema-view script with and it works great as long as I don’t have array field types. When I do, it creates duplicate entries in the BigQuery table.

This schema create 116 entries per every firestore document:

{
  "fields": [
    {
      "name": "field1",
      "type": "string"
    },
    {
      "name": "field2",
      "type": "number"
    },
    {
      "name": "field3",
      "type": "array"
    },
    {
      "name": "field4",
      "type": "array"
    },
    {
      "name": "field5",
      "type": "map",
      "fields": [
        {
          "name": "field5nested1",
          "type": "string"
        },
        {
          "name": "field5nested2",
          "type": "boolean"
        },
        {
          "name": "field5nested3",
          "type": "array"
        },
        {
          "name": "field5nested4",
          "type": "array"
        }
      ]
    }
  ]
}

This one doesn’t

{
  "fields": [
    {
      "name": "field1",
      "type": "string"
    },
    {
      "name": "field2",
      "type": "number"
    },
    {
      "name": "field5",
      "type": "map",
      "fields": [
        {
          "name": "field5nested1",
          "type": "string"
        },
        {
          "name": "field5nested2",
          "type": "boolean"
        }
      ]
    }
  ]
}

I should add that field3 and field4 are array of firestore references, and field5nested3, field5nested4 are array of maps.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dackers86commented, Nov 19, 2021

Base on that schema I have produced case with the following results…

  await ref.set({
    field1: "test",
    field2: 1000,
    // field3: [ref1, ref2],
    // field4: [ref1, ref2],
    field5: {
      field5nested1: "field5nested1_example",
      field5nested2: true,
      field5nested3: [
        { field5nested3_array_1: "field5nested3__array1__example" },
        { field5nested3_array_2: "field5nested3__array2__example" },
        { field5nested3_array_3: "field5nested3__array3__example" },
      ],
      field5nested4: [
        { field5nested4_array_1: "field5nested4_array1__example" },
        { field5nested4_array_2: "field5nested4_array2__example" },
        { field5nested4_array_3: "field5nested4_array3__example" },
      ],
    },
  });

![image](https://user-images.githubusercontent.com/2060661/142433516-0d1c51c7-286a-424e-965a-c4a24b01a009.png)

image

I suppose the confusion is that this returns n amount of rows from a complex structure into a flat version of the data.

Does this adequately replicate the data that you are seeing from your own database?

0reactions
alexcastillocommented, Dec 9, 2021

Yes, it’s good to know that’s the intended behavior. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add an array to Widget Server script to remove duplicates
Solved: Hi, I am needing some help with adding an array to remove duplicate records in the Server script of my custom widget....
Read more >
Duplicate data getting added into collection - MongoDB
Hi, I have created a mongoose model as below, and set recordId field to “unique: true” to handle duplicate entry. But when through...
Read more >
Allow same array entry in different documents #6264 - GitHub
In my schema, I have a property, keywords, which is an array. Mongoose automatically prevents entering the same array value in different ...
Read more >
Duplicate values inside Array in Mongoose Schema
What I am trying to do I have a document with teamid as the unique identifier and name of the team.
Read more >
Typescript - Finding Duplicate Elements in an Array
Have you ever wanted to find some duplicate elements in an array? Lets take a look at how to do just that in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found