Skip to content
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

mongodb not find column? #22465

Closed
hope1234567hope opened this issue Jun 21, 2024 · 1 comment
Closed

mongodb not find column? #22465

hope1234567hope opened this issue Jun 21, 2024 · 1 comment

Comments

@hope1234567hope
Copy link

in mongodb, I INSERT some data like this:the first redord password and arrayF1 is null
develop:PRIMARY> db.c1.insertMany([
... {
... "userid": 2,
... "username": "anotherUser",
... "phone": "anotherPhone",
... "email": "anotherEmail",
... "password": {},
... "arrayF1": []
... },
... {
... "userid": 3,
... "username": "yetAnotherUser",
... "phone": "yetAnotherPhone",
... "email": "yetAnotherEmail",
... "password": "yetAnotherPassword",
... "arrayF1": ["yetAnotherValue1"]
... },
... {
... "userid": 4,
... "username": "newAnotherUser",
... "phone": "newAnotherPhone",
... "email": "newAnotherEmail",
... "password": "newAnotherPassword",
... "arrayF1": ["anotherValue1", "anotherValue2"]
... },
... {
... "userid": 5,
... "username": "1newAnotherUser",
... "phone": "1newAnotherPhone",
... "email": "1newAnotherEmail",
... "password": "1newAnotherPassword",
... "arrayF1": ["1newAnother"]
... }
... ]);

now in trino-client

trino:hellodb> show create table c1;
Create Table

CREATE TABLE mongodb.hellodb.c1 (
userid double,
username varchar,
phone varchar,
email varchar
)
(1 row)

trino:hellodb> select * from c1;
userid | username | phone | email
--------+-----------------+------------------+------------------
2.0 | anotherUser | anotherPhone | anotherEmail
5.0 | 1newAnotherUser | 1newAnotherPhone | 1newAnotherEmail
4.0 | newAnotherUser | newAnotherPhone | newAnotherEmail
3.0 | yetAnotherUser | yetAnotherPhone | yetAnotherEmail
(4 rows)

why not find "password" and "arrayF1" column,how can reslove it?
Due to geographical reasons, I am unable to join the at community Slack。please help me

@ebyhr
Copy link
Member

ebyhr commented Jun 21, 2024

The connector guesses the schema definition based on a sample document during the first access. You need to fix the definition with ALTER TABLE statements or manually update the internal _schema. See https://trino.io/docs/current/connector/mongodb.html#mongodb-schema-collection for more details.

@ebyhr ebyhr closed this as completed Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants