Skip to content

Update map fields #304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Update map fields #304

wants to merge 6 commits into from

Conversation

tothmano
Copy link
Collaborator

@tothmano tothmano commented Jun 3, 2025

No description provided.

## Map fields and flattened fields

The parent map field and its flattened subfields can appear in the same dataset. For example, ingesting the following JSON adds a map field (`geo`) and two flattened fields (`geo.city`, `geo.country`) to the dataset. Axiom treats them as separate fields and doesn’t maintain a relationship between them.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ingesting this doesn't create a map field; just the two flattened fields. to create a map field, you can do so via the api or now, in app.

the point about axiom treating them differently is if you have a map field that shares the same keys/values as a flattened version. theres no conflicts there, like you mentioned

Copy link
Contributor

@c-ehrlich c-ehrlich Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ollie is right about this

the steps to end up in this situation are:

  1. geo is not a map field
  2. ingest
{
  "geo": {
    "city": "Paris",
    "country": "France"
  }
}

this gets put into geo.city and geo.country

  1. make geo a map field
  2. ingest the same
{
  "geo": {
    "city": "Paris",
    "country": "France"
  }
}

this gets put into geo

(or in opposite order)


- Projecting away all subfields (in this example, `geo.city` and `geo.country`) doesn’t remove the parent map field `geo` unless it is explicitly projected away.
- Fields metadata may still include entries for projected-away fields if the map field is preserved.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wouldn't note this, those are implementation details i needed at the time but customers dont see it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, the information below about `['geo']['city'] being different from ['geo.city'] is enough here. imo the above only makes it more confusing to someone who is reading about this for the first time.

@tothmano tothmano requested review from c-ehrlich and removed request for mhr3 June 10, 2025 06:32

Support for creating your own map fields is coming in early 2025. To express interest in the feature, [contact Axiom](https://axiom.co/contact).
</Note>
Axiom automatically creates map fields in datasets that use [OpenTelemetry](/send-data/opentelemetry) and you can create them yourself.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Axiom automatically creates map fields in datasets that use [OpenTelemetry](/send-data/opentelemetry) and you can create them yourself.
Axiom automatically creates the `attributes.custom` map field in datasets that use [OpenTelemetry](/send-data/opentelemetry). You can also create other map fields in any dataset.

the current "and you can create them yourself" feels unclear imo. not sure my suggestion is exactly right though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I think it's not just attributes.custom that we create in OTel datasets. I would not specify the actual fields here. But the second part of the sentence could surely be improved, so implemented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik that's the only one. which other ones do you know of?

Copy link
Collaborator Author

@tothmano tothmano Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought resource.custom could also be one of them? Anyway, it's OK not to specify it here. We do it elsewhere.

## Map fields and flattened fields

The parent map field and its flattened subfields can appear in the same dataset. For example, ingesting the following JSON adds a map field (`geo`) and two flattened fields (`geo.city`, `geo.country`) to the dataset. Axiom treats them as separate fields and doesn’t maintain a relationship between them.
Copy link
Contributor

@c-ehrlich c-ehrlich Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ollie is right about this

the steps to end up in this situation are:

  1. geo is not a map field
  2. ingest
{
  "geo": {
    "city": "Paris",
    "country": "France"
  }
}

this gets put into geo.city and geo.country

  1. make geo a map field
  2. ingest the same
{
  "geo": {
    "city": "Paris",
    "country": "France"
  }
}

this gets put into geo

(or in opposite order)


- Projecting away all subfields (in this example, `geo.city` and `geo.country`) doesn’t remove the parent map field `geo` unless it is explicitly projected away.
- Fields metadata may still include entries for projected-away fields if the map field is preserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, the information below about `['geo']['city'] being different from ['geo.city'] is enough here. imo the above only makes it more confusing to someone who is reading about this for the first time.

Comment on lines 65 to 72
- `where ['map_field'].property1.property2 == 14`
- `where ['map_field']['property1']['property2'] == 14`

If an entity name has spaces (` `), dots (`.`), or dashes (`-`), you can only use index notation for that entity. You can use dot notation for the other entities. For example:

- `where ['map.field']['property.name1']['property.name2'] == 14`
- `where ['map.field'].property1.property2 == 14`
Copy link
Contributor

@c-ehrlich c-ehrlich Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this was already merged in a previous pr. but as far as i can tell all of these apl examples will not return the desired events.

the only correct syntax is ['map.field']['something.inside.of.it']

see: https://app.dev.axiomtestlabs.co/axiomers-ft83/query?qid=4O0s3Ki3fPa-sxyen5

aside: imo even if there is some other way that works, we should only teach ['map.field']['something.inside.of.it'].

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@c-ehrlich Thanks for this. I don't know if this recently got broken because the original PR underwent a thorough review process: #65

I've tried to implement your suggestions here: 61e9181

The problem is that where ['map.field']['property.name1']['property.name2'] == 14 still doesn't work but then I don't know how else to deal with property names with special characters like dots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants