Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Querying azure table storage for null values

Tags:

Does anyone know the proper way to query azure table storage for a null value. From what I've read, it's possible (although there is a bug which prevents it on development storage). However, I keep getting the following error when I do so on the live cloud storage:

One of the request inputs is not valid.

This is a dumbed down version of the LINQ query that I've put together.

var query = from fooBar in fooBarSVC.CreateQuery<FooBar>("FooBars")         where fooBar.PartitionKey == kPartitionID             && fooBar.Code == kfooBarCode             && fooBar.Effective_Date <= kFooBarDate.ToUniversalTime()             && (fooBar.Termination_Date > kFooBarDate.ToUniversalTime() || fooBar.Termination_Date == null)         select fooBar; 

If I run the query without checking for null, it works fine. I know a possible solution would be to run a second query on the collection that this query brings back. I don't mind doing that if I need to, but would like to know if I can get this approach to work first.

Anyone see anything obvious I'm doing wrong?

like image 948
Brosto Avatar asked Nov 19 '10 19:11

Brosto


People also ask

How do I retrieve data from Azure table storage?

Enter an Account Name, Account Key, and Table Name on the Azure Table tab of the New Session dialog. Select either HTTP or HTTPS as the connection Protocol. Ensure that the Analysis Grid viewer is selected in the Start With drop-down list. Start retrieving data by clicking the Start button in the New Session dialog.

How do you check null in kusto?

Data ingestion and null values If you run the above query in Kusto. Explorer, all true values will be displayed as 1 , and all false values will be displayed as 0 . Kusto doesn't offer a way to constrain a table's column from having null values. In other words, there's no equivalent to SQL's NOT NULL constraint.

What is RowKey in Azure table storage?

The row key is a unique identifier for an entity within a given partition. Together the PartitionKey and RowKey uniquely identify every entity within a table. The row key is a string value that may be up to 1 KiB in size. You must include the RowKey property in every insert, update, and delete operation.


1 Answers

The problem is that because azure table storage does not have a schema, the null column actually doesn't exist. This is why your query is not valid. there is no such thing as a null column in table storage. You could do something like store an empty string if you really have to. Really though the fundamental issue here is that Azure table storage really is not built to be queried by any columns other than partition key and row key. Every time you make a query on one of these non-standard columns you are doing a table scan. If you start to get lots of data you are going to have a very high rate of query time outs. I would suggest setting up a manual index for these types of queries. For example, you could store the same data in the same table but with different values for the Row key. Ultimately, if your are app is not getting crazy high usage I would just use SQL Azure as it will be much more flexible for the types of queries you are doing.

Update: Azure has a great guide on table storage design that I would recommend reading. http://azure.microsoft.com/en-us/documentation/articles/storage-table-design-guide/

like image 159
Nathan Totten Avatar answered Oct 13 '22 19:10

Nathan Totten