Segment with Native Query?

Hey,

Is there any way to create a Segment with a Native query? I need to segment on data within an array from MongoDB.

data[].SegmentData === “somedata”

{
“data”: [
{
“SegmentData”: “somedata”
},
{
“SegmentData”: “someotherdata”
}

]

}

Any pointers or help greatly appreciated,

Thanks in advance

Hi @pete_my
I’m not sure what you’re asking, since I don’t know MongoDB, but is this specific to Metabase or a general MongoDB question?

Currently it’s not possible to use Native/SQL queries as segment/metric:
https://github.com/metabase/metabase/issues/5194 - upvote by clicking :+1: on the first post

For general MongoDB question, then you’ll probably find better help in one of their communities:
https://www.mongodb.com/community-support-resources

Thanks @flamber. Apologies for the confusion, this was a Metabase question, not MongoDB.

I’ve upvoted the Issue, this is the feature I’m looking for.

Are there any workarounds for this? I tried quickly hacking the Segment table in the DB to include a native query, but it didn’t work. :smiley:

@pete_my
I would highly recommend not messing around in the metadata manually - make sure you have backups, since you can easily corrupt it.
I’m not sure what you’re trying to do, but with other databases you can get around a lot of things with Views or Procedures - I don’t know Mongo.
You might also be interested in this issue:
https://github.com/metabase/metabase/issues/10327 - upvote by clicking :+1: on the first post

Thanks, yes, everything is backed up and safe. :slight_smile: It was worth the quick experiment.

I’ll keep an eye on the mentioned issues and continue with my other workaround.

Cheers.