INDEXOF returning "Scalars can be only used with projections" error - apache-pig

Am trying to find whether one field is sub string of another field by using INDEXOF(f1,f2) > -1 where f1,f2 are both char arrays. But am getting error message as "Scalars can be only used with projections".
Is this error message because of, lack of support for two variables comparison in INDEXOF or something else? Can some one help with this?
Thanks in advance.

Related

WorksheetFunction.Countif Line not reading my Address function

I am trying to have a macros that will pull numbers no matter where they are pasted. I am using index match to pull these from an input. I have been successful in finding the "Addresses" for what I am looking for. How do I get functions to reference the Address in the Cells and not the Cells themselves?
It is right on the tip of my tongue and it is maddening. When I put
Application.WorksheetFunction.Countif(Indirect(Address(5,9,True,"Sheet2")), Range("C1").Value)>0= True Then
There is a function error. When I put in
Application.WorksheetFunction.Countif(Variable.Address(Extrenal:=True), Range("C1").Value)>0= True Then
There is a mismatch error
I have tried Indirect(address()) but when I plug this into Index match it says that there is an error. Index(indirect(address()),Match(Ref,Indirect(Address),0))
I have also been trying to use the address in a countif statement.
If Application.WorksheetFunction.Countif(Indirect(Address(5,9,True,"Sheet2")), Range("C1").Value)>0= True Then...
Also,
(Index(indirect(address()),Match(Ref,Indirect(Address),0))
I am getting as mentioned a mismatch error and a function error. I will take any method to fix either of these.
thank you all for your input. This is what I came up with.Dim SKU as Range;Dim SKUR as Range;Dim SKU1 as String;Dim Variable as String;Dim VariableR as Range;Set SKU = Worksheets("Sheets1").Range("A:AC").Find("Number");Set SKUR =SKU.EntireColumn;Variable - SKUR.Address(External:=True);SetVariableR=Range(Variable);SKU1=Application.WorksheetFunction.IfError(Application.WorksheetFunction.Index(VariableR,(Application.WorksheetFunction.Match((Range("C1").Value),VariableR,0)),0);Worksheets("Sheet2").Range("C5").Value = SKU1
Again, this is what I came up for using index match in VBA using an address range I found.Some reason it won't let me post it with the spaces so I am using semi colons to separate lines, please take them out when using this.

Can't quote array - rails sql

Im trying to create a sql query dynamically with the following syntax:
Company.joins(:founder_persons)
.where("people.first_name like people[:first_name]", {people: {first_name: 'm%'}})
But running this on the rails console gives me TypeError: can't quote Array. Im guessing this is not how we use the where string? What's the right way to fix this error? Thanks.
One reason this error can occur is with a nested array used as SQL value.
Example:
Article.where(author: ['Jane', 'Bob'])
works, but:
Article.where(author: ['Jane', ['Bob']])
would give the error. A quick fix would be to run flatten on the array.
(Mentioning this since this page comes up when searching for the confusing error "Can't quote array".)
You could bind any value and then assign it, this way they should coincide in numbers, like:
Model.joins(:join_table)
.where('models.first_attribute LIKE ? AND models.second_attribute LIKE ?', value_for_first_attr, value_for_second_attr)
If using an array you should access each index you want to compare, or you can precede a splat *, and specify just one value, like:
Model.joins(:join_table)
.where('models.first_attribute LIKE ? AND models.second_attribute LIKE ?', *array_of_values)
Note although this way you're passing the "whole" array it should also coincide in size or numbers, otherwise it'd raise an ActiveRecord::PreparedStatementInvalid error depending if there are more or less elements than needed.

Access Javascript Array with numeric key

I tried to access the following value in an multidimensional array:
var temp = allSliderData[i]['slider_full'][j].path;
and it works fine, but the following not
var temp2 = allSliderData[i]['slider_thumbs'][j].285x255;
with the answer
"SyntaxError: identifier starts immediately after numeric literal"
I now tried escapings, array functions .. this message is good known in stackoverflow .. but still no luck.
Could anybody help out?
THANKS!!
Something like that won't work. You can't have a property named "2" there. What exactly do you want to do?

substring and the indexOf method

My assignment in Visual Basic 2010 is to build a order form that has two text boxes, one for the name and the other for the address.
And we're suppose to use the IndexOf method on the address.
I understand that IndexOf returns the position of a character and the number of characters.
What would be the purpose of using the IndexOf method on the address in this instance?
I don't understand what I would be searching for when the user types in it's address that's going to be numbers and string characters.
I think I understand what the IndexOf method does, somewhat, but why and what would I use it to achieve?
You'd typically use IndexOf to -
See if a string contained something
If someString.IndexOf("Avenue") > - 1 Then
'do something
End If
Get the start position of a value in a string , this could then be used to extract part of the string. e.g. someString.Substring(someString.IndexOf("#"),10) would get then next ten characters starting from where the "#" character was found in your string.
Bear in mind you'll always need to handle scenarios where IndexOf will return -1 if it does not find the string your searching for, so your code will have to handle that eventuality.
Since this is a homework question, I will answer with a question or several:
How would you normally enter a full address into a text box?
How would each part of the address be distinguishable from another?
Once you figure out how this can be done, think about IndexOf again.

Newbie issue with LINQ in vb.net

Here is the single line from one of my functions to test if any objects in my array have a given property with a matching value
Return ((From tag In DataCache.Tags Where (tag.FldTag = strtagname) Select tag).Count = 1)
WHERE....
DataCache.Tags is an array of custom objects
strtagname = "brazil"
and brazil is definitely a tag name stored within one of the custom objects in the array.
However the function continually returns false.
Can someone confirm to me that the above should or should not work.
and if it wont work can someone tell me the best way to test if any of the objects in the array contain a property with a specific value.
I suppose in summary I am looking for the equivalent of a SQL EXISTS statement.
Many thanks in hope.
Your code is currently checking whether the count is exactly one.
The equivalent of EXISTS in LINQ is Any. You want something like:
Return DataCache.Tags.Any(Function(tag) tag.FldTag = strtagname)
(Miraculously it looks like that syntax may be about right... it looks like the docs examples...)
Many Thanks for the response.
Your code did not work. Then I realised that I was comparing to an array value so it would be case sensitive.
However glad I asked the question, as I found a better way than mine.
Many thanks again !