MongoDB to BigQuery: _id recieved not hashed

Hi there, 

While using the connector and returning the data without being flattened, I'm recieving ObjectIds like this

 

"_id":{"timestamp":1638209485,"counter":13050635,"randomValue1":12445288,"randomValue2":25}

 

instead of the hash I see in MongoDB. How can I fix this? 

Solved Solved
1 3 132
1 ACCEPTED SOLUTION

Looks like you are using Dataflow. This is not Integration Connector. For Dataflow, please refer to their support channel: https://cloud.google.com/dataflow/docs/support/getting-support

View solution in original post

3 REPLIES 3

Could you please share project ID and connection details?

 msedge_1mAc5k0b1K.png

project ID is "manteca-bi". In this screenshot I tried to run an UDF to parse the _id to string but that didn't work either (had console errors). Here is the script:

 

/**
 * Converts a MongoDB ObjectId to its string representation.
 *
 * @PARAM {Object} obj The MongoDB document.
 * @returns {String} The string representation of the ObjectId.
 */
function parseObjectIdToString(obj) {
    if (!obj._id) {
      return 'null';
    }
    // Check if _id is already a string
    if (typeof obj._id === 'string') {
      return obj._id;
    }
    // Assuming _id is an ObjectId
    return obj._id.toString();
  }

 

  

Looks like you are using Dataflow. This is not Integration Connector. For Dataflow, please refer to their support channel: https://cloud.google.com/dataflow/docs/support/getting-support