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

getTags vs. getFields #260

Open
lvn2007 opened this issue Aug 19, 2024 · 4 comments
Open

getTags vs. getFields #260

lvn2007 opened this issue Aug 19, 2024 · 4 comments

Comments

@lvn2007
Copy link

lvn2007 commented Aug 19, 2024

Not sure if I understand it correctly but it seems that the getTags call is returning Field instead of tags.
This was validated using Influx CLI client:

CMD:

SHOW FIELD KEYS ON BENCH_DB

CMD Returns:

> SHOW FIELD KEYS ON BENCH_DB
name: BENCH_DB
fieldKey fieldType
-------- ---------
col0     string
col1     string
col10    string
col11    string
col12    string
col13    string
col14    string
col15    string
col16    string
col17    string
col18    string
col19    string
col2     string
col20    string
col21    string
col22    string
col23    string
col24    string
col25    string
col26    string
col27    string
col28    string
col29    string
col3     string
col30    string
col31    string
col4     string
col5     string
col6     string
col7     string
col8     string
col9     string
>

getTags: When calling getTags, it's returning fields shown in CMD. However, calling getFields, it's not returning anything.

std::vector<influxdb::Point> unaryQueryRep = influxClient->query("SELECT * FROM BENCH_DB WHERE time = 946684800ms");

for (auto j: unaryQueryRep) {
    std::cout << j.getTags() << "\n";
}
@offa offa added the question label Aug 20, 2024
@offa
Copy link
Owner

offa commented Aug 20, 2024

Please add versions of the library and influxdb version used.

Is there a minimal example to reproduce the issue?

The related test case might be a good starting point, but does not show the problem.

@lvn2007
Copy link
Author

lvn2007 commented Aug 22, 2024

I'm using InfluxDB v1.6.7~rc0 and influxcxx v0.7.1
After some debugging, it seems that for addField(key, value), if I have value as string, inserted data will become Tag instead of Field. However, if I remove "asdf" in makeSinglePoint function, values exist in .getFields() call.

Please see the below for the example that reproduce the said issue.

#include <InfluxDBFactory.h>
#include <iostream>
#include <chrono>
#include <string>
#include <vector>

influxdb::Point makeSinglePoint() {
    influxdb::Point toReturn{"BENCH_DB"};

    std::chrono::time_point<std::chrono::system_clock> timestamp(std::chrono::milliseconds(946684800));
    toReturn.setTimestamp(timestamp);

    for (int i = 1; i < 32; i++) {
        toReturn.addField("col" + std::to_string(i - 1), "asdf" + std::to_string(i));
    }
    return toReturn;
}

int main(int argc, char const *argv[])
{
    // Init InfluxDB instances
    auto db = influxdb::InfluxDBFactory::Get("http://192.168.1.155:8086?db=BENCH_DB");

    // Create DB
    db->createDatabaseIfNotExists();

    // Make single Point
    influxdb::Point currPoint = makeSinglePoint();

    // Insert
    db->write(std::move(currPoint));

    // Query
    std::vector<influxdb::Point> unaryQueryRep = db->query("SELECT * FROM BENCH_DB WHERE time = 946684800ms");

    std::cout << unaryQueryRep.at(0).getFields() << "\n";
}

@offa
Copy link
Owner

offa commented Aug 25, 2024

Thanks, I'm able to reproduce the issue with your example.

@offa offa added this to the v0.8.0 milestone Aug 25, 2024
@offa
Copy link
Owner

offa commented Sep 1, 2024

The original implementation uses the type to determine field (everything except string) or tag (string).

The response JSON doesn't provide any information to separate field and tag strings, but only columns and values.

@offa offa removed this from the v0.8.0 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants