Filtering rows that contain a Rollup formula

Hi there,

First of all thanks for making this awesome Airtable / NocoDB / Baserow alternative. My first impressions are very positive and I especially like the Big Data option, in case you outgrow the default row limits.

So one issue I am running into is that I want to request rows via the API that match some specific filter. I noticed that the List Filtered Rows endpoint is Deprecated since version 2.3, so I was looking into the alternative: SQL Query.

So I do this simple Query:

{
  "sql": "SELECT * from RecipeVariations",
    "convert_keys": true
}

But sadly, when I query the desired table, it returns Rollup formula columns as

 "Prot": "#VALUE!",

And this is exactly the value I want to filter on. So when I do this filtered query:

{
  "sql": "SELECT * from RecipeVariations WHERE Prot=50",
    "convert_keys": true
}

It doesn’t return any relevant rows.

So my two questions are:

  1. Is the query endpoint returning rollup values as #VALUE! expected behaviour?
  2. What other way, that is not deprecated, could I use to filter the rows endpoint?

Thanks in advance for any response :slight_smile:

ps: I am on the cloud version.

EDIT: I managed to create a view with the required filter in the UI. Now I can use that with the List Rows endpoint. Like so:

view_name=P 25-35

However, the List Rows endpoint returns

"Photo": "[object Object]",

For a lookup column with attachment. Where the List Rows (with SQL) returns a nice and working object with a url to the file, for the exact same table and column. Any ways to overcome this without creating another request? I am trying to minimize requests in order to stay away from API limits in future use. Another alternative would be to use a proxy API, but I would rather delay that.

EDIT2: I notice now that for some columns using the query api a ‘Link formula’ does show up a value, and in some cases it doesn’t. It is hard to really see a pattern. It almost seems as if when table A has a one to many relationship to table B and Table B has a column with Link formula to a single record in table A, it does show up, but when Table B has a many to many relationship to Table C and you have link formula column in Table B referring to multiple rows in table C, it shows up blank with the query API. This does not happen with the view filtered list api.

So for instance this does work:

{
  "sql": "SELECT Photo from RecipeVariations",
    "convert_keys": true
}

And gives response:

{
    "success": true,
    "error_message": "",
    "results": [
        {
            "Photo": [
                {
                    "name": "bacon worst met ei.jpg",
                    "size": 211829,
                    "type": "file",
                    "url": "https://cloud.seatable.io/workspace/34414/asset/1264b3bb-7def-4b9c-a8b8-c808e701cdaf/files/2023-04/bacon%20worst%20met%20ei.jpg"
                }
            ]
        },
        {
            "Photo": [
                {
                    "name": "bacon worst met ei.jpg",
                    "size": 211829,
                    "type": "file",
                    "url": "https://cloud.seatable.io/workspace/34414/asset/1264b3bb-7def-4b9c-a8b8-c808e701cdaf/files/2023-04/bacon%20worst%20met%20ei.jpg"
                }
            ]
        },
        {
            "Photo": [
                {
                    "name": "bacon worst met ei.jpg",
                    "size": 211829,
                    "type": "file",
                    "url": "https://cloud.seatable.io/workspace/34414/asset/1264b3bb-7def-4b9c-a8b8-c808e701cdaf/files/2023-04/bacon%20worst%20met%20ei.jpg"
                }
            ]
        },
        {
            "Photo": [
                {
                    "name": "bacon worst met ei.jpg",
                    "size": 211829,
                    "type": "file",
                    "url": "https://cloud.seatable.io/workspace/34414/asset/1264b3bb-7def-4b9c-a8b8-c808e701cdaf/files/2023-04/bacon%20worst%20met%20ei.jpg"
                }
            ]
        }
    ],
    "metadata": [
        {
            "key": "pfj2",
            "name": "Photo",
            "type": "link-formula",
            "data": {
                "array_data": null,
                "array_type": "file",
                "formula": "lookup",
                "level1_linked_table_column_key": "EBsu",
                "link_column_key": "787V",
                "operated_columns": [
                    "787V"
                ],
                "result_type": "array"
            }
        }
    ]
}

And this doesn’t

{
  "sql": "SELECT Proteins from RecipeVariations",
    "convert_keys": true
}

Gives:

{
    "success": true,
    "error_message": "",
    "results": [
        {
            "Proteins": []
        },
        {
            "Proteins": []
        },
        {
            "Proteins": []
        },
        {
            "Proteins": []
        }
    ],
    "metadata": [
        {
            "key": "yBG3",
            "name": "Proteins",
            "type": "link-formula",
            "data": {
                "array_data": {},
                "array_type": "number",
                "formula": "lookup",
                "level1_linked_table_column_key": "7H5J",
                "link_column_key": "c0np",
                "operated_columns": [
                    "c0np"
                ],
                "result_type": "array"
            }
        }
    ]
}

We will give it a check in the next week.

Hi,
thanks for the feedback. However, when I was trying to reproduce the problem you described about the sql query with API, everything seems so fine and the problem did not show up in my base. May be I didn’t know the full picture of how you use it.

If you don’t mind, could you please make a share link of your base for us, and we will get straight to the issues asap.

And FYI, the “[Object object]” returned is exactly the value we designed in the List Rows API, and it’s not an issue.

Thanks for getting back to me. I have copied the base to a base called base_for_issue. How can I share it safely with you? I don’t exactly like to make it public.

So getting the url for an attachment is not a feature of the List Rows API I understand? If I would be able to get all the required data through the Query API this is no issue for me :slight_smile:

Hi, you can send the share link throught the private message in the forum。

1 Like

Please see the link in your pm inbox. Thanks for looking into this! :slight_smile:

Thank you for sharing the bases !

And, Maybe I know the reason why #value returned for rollup. The column type of table FoodNutrient should be number instead of text. The text column may cause a series problem among tables with a link chains when you doing some numeric calculations. Such as the value of ‘prot’’ of 'Cals 'are based on a formula inside of which have a citation of the column of other table.

Please try to change the column type to number and check if the problems are solved.

3 Likes

Such genius thinking to find such a n00b mistake! Thanks! That indeed solved the issue and now I’ve switched the columns from text to number they show up nicely in the query api. All is solved thank you :smiley:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.