I am creating a knowledge graph in SPARQL. I am importing data from a csv file.
Now I want to filter a data corresponding to a country.
In the csv I don't want to make data in column to all lower or upper case.
Now I want to filter a data, such that I want a SPARQL query that can get me data which is case insensitive (to give data either when typed lower or upper case).
I used the FILTER statement as below:
FILTER(?country, "Japan").
How to make Japan case insensitive
FILTER(?country, "Japan").
Expecting a filter or any other statement that makes it case insensitive
One way is to convert ?country to lower case and test against the lower case version as in:
FILTER (lcase(?country) = "japan")
Likewise you could test it after converting to upper case
FILTER (ucase(?country) = "JAPAN")
Related
all,
I encountered a problem after I used the function sort_array_by() in hive. I found after use that function, the original column names became lower cases, while the original ones contained some capital letters.
My data is like:
[{"tagName":"a","valueDegree":100},{"tagName":"b","valueDegree":200}] , and the column name is cc.
what I want to do is to reorder the data by the column 'valueDegree' in descending order.Namely, I want the data to be like the following:
[{"tagName":"b","valueDegree":200},{"tagName":"a","valueDegree":100}].
I used the functionsort_array_by().
However, after I used sort_array_by(cc, 'valueDegree', 'DESC'), the order was correct but the column names(tagName, valueDegree) in the struct were changed into lower case accidentally. I got the result like:
[{"tagname":"b","valuedegree":200},{"tagname":"a","valuedegree":100}]
Anyone knows how to keep the original column names?
When trying to list down all tables names in a database having a specific name format, the following query works fine :
show tables like '*case*';
while the following does not
show tables like '%case%';
On the other hand, when comparing the actual data inside string columns its the vice-versa case
Working query :
select column from database.table where column like '%ABC%' limit 5;
Not working query :
select column from database.table where column like '*ABC*' limit 5;
What's the difference between the 2 operators * and % ?
This is the difference between regular expressions and like patterns.
LIKE is built into the SQL language. It has two wildcards:
% represents any number of characters including zero.
_ represents exactly one character.
Regular expressions are much more flexible for matching almost any pattern in a string.
When SQL was invented, I don't think regular expressions were in common use in computer systems -- at the very least, the folks at IBM who worked on relational databases may not have been familiar with the folks at ATT who were inventing Unix.
Regular expressions are much more powerful than LIKE patterns, of course. And Hive supports them via the RLIKE operator (and some other functions).
The SHOW functionality is not standard SQL. So, the developers of Hive chose the more flexible method for pattern matching.
HiveQL attempts to mimic the SQL, but it does not strictly follow its standards.
The usage of the wildcards are not pertinent to the LIKE clause, but to the statement itself. SHOW statements validate the wildcards based on the Java regular expression whereas when it comes to SELECT statements, Hive tries to stick with the SQL's wildcard validation.
I need to convert the name of the table into lower before passing it for the query.
Irrespective of which case in pass the value for parameter $1 i need it to be converted into lower case before executing the below query.
QUERY:
show tables like '$1';
I have tried something like
QUERY
show tables like 'lower($1)';
But this doesn't work.
please help.
Your response would be highly appreciated
Impala identifiers are always case-insensitive. That is, tables named
t1 and T1 always refer to the same table, regardless of quote
characters. Internally, Impala always folds all specified table and
column names to lowercase. This is why the column headers in query
output are always displayed in lowercase.
Impala Documentation
All the below queries will give same result as internally impala converts to lowercase.
show tables like 'test*';
show tables like 'TeSt*';
show tables like 'TEST*';
I'm running a search with a type field. I'd like to show results of a certain type ONLY if two other field have values for them. So in my filter query I thought it would be(type:sometype AND field1:* AND field2:*) but wildcard queries can't start with the *.
Use a range query to express "field must have any value", e.g.:
type:sometype AND field1:[* TO *] AND field2:[* TO *]
Hopefully this is easy to explain, but I have a lookup transformation in one of my SSIS packages. I am using it to lookup the id for an emplouyee record in a dimension table. However my problem is that some of the source data has employee names in all capitals (ex: CHERRERA) and the comparison data im using is all lower case (ex: cherrera).
The lookup is failing for the records that are not 100% case similar (ex: cherrera vs cherrera works fine - cherrera vs CHERRERA fails). Is there a way to make the lookup transformation ignore case on a string/varchar data type?
There isn't a way I believe to make the transformation be case-insensitive, however you could modify the SQL statement for your transformation to ensure that the source data matches the case of your comparison data by using the LOWER() string function.
Set the CacheType property of the lookup transformation to Partial or None.
The lookup comparisons will now be done by SQL Server and not by the SSIS lookup component, and will no longer be case sensitive.
You have to change the source and as well as look up data, both should be in same case type.
Based on this Microsoft Article:
The lookups performed by the Lookup transformation are case sensitive. To avoid lookup failures that are caused by case differences in data, first use the Character Map transformation to convert the data to uppercase or lowercase. Then, include the UPPER or LOWER functions in the SQL statement that generates the reference table
To read more about Character Map transformation, follow this link"
Character Map Transformation