I am learning pig myself, I am stuck with one error.
This is written in macro script to understand modular programming in Pig. the issue is that I am trying to use string parameters with $ by referencing relation name :: then immediately parameter string substitution with $. The error is:
unexpected character $
How to go ahead on this?
define dividend_analysis (daily, year, daily_symbol, daily_open, daily_close)
returns analyzed {
divs = load '/PigData1/NYSE_dividends.txt'as (exchange:chararray, symbol:chararray, date:chararray, dividends:float);
divisthisyear = filter divs by date matches '$year-.*';
dailythisyear = filter $daily by date matches '$year-.*';
jnd = join divisthisyear by symbol, dailythisyear by $daily_symbol;
$analyzed = foreach jnd generate dailythisyear.$daily_symbol,$daily_close - $daily_open;
};
daily = load '/PigData1/NYSE_daily.txt'as (exchange:chararray, symbol:chararray, date:chararray, open:float, high:float, low:float, close:float, volume:int, adj_close:float);
results = dividend_analysis(daily, '2009', 'symbol', 'open', 'close');
the error message is from pig is ...
<line 7, column 53> Unexpected character '$'
2016-12-09 16:14:04,283 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 7, column 53> Unexpected character '$'
Details at logfile: /home/hadoop/pig_1481278051535.log
grunt> exec macro1.pig
<line 7, column 53> Unexpected character '$'
2016-12-09 17:00:37,723 [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1200: <line 7, column 53> Unexpected character '$'
Details at logfile: /home/hadoop/pig_1481278051535.log
Here is change made for your script , try this one
define dividend_analysis (daily, year, daily_symbol, daily_open, daily_close)
returns analyzed {
divs = load '/user/data/NYSE_dividends'as (exchange:chararray, symbol:chararray, date:chararray, dividends:float);
divisthisyear = filter divs by date matches '.*$year.*';
dailythisyear = filter $daily by date matches '.*$year.*';
jnd = join divisthisyear by symbol, dailythisyear by $daily_symbol;
$analyzed = foreach jnd generate $1 ,$daily_close - $daily_open; };
daily = load '/user/data/NYSE_daily'as (exchange:chararray, symbol:chararray, date:chararray, open:float, high:float, low:float, close:float, volume:int, adj_close:float);
results = dividend_analysis(daily, '2009', 'symbol', 'open', 'close');
Related
I'm trying to convert my text as token, but I keep getting this error
## Selection only the "Body" column to analize the text
email_body <- as.tibble(data_email_pp$body)
df <- email_body %>% unnest_tokens(word, email_body)
Error:
! Must extract column with a single valid subscript.
✖ Subscript var has the wrong type tbl_df<value:character>.
ℹ It must be numeric or character.
Backtrace:
email_body %>% unnest_tokens(word, email_body)
tidytext::unnest_tokens(., word, email_body)
dplyr:::pull.data.frame(tbl, !!input)
tidyselect::vars_pull(names(.data), !!enquo(var))
tidyselect:::pull_as_location2(loc, n, vars)
vctrs::vec_as_subscript2(i, arg = "var", logical = "error")
vctrs:::result_get(...)
Error:
✖ Subscript var has the wrong type tbl_df<value:character>.
ℹ It must be numeric or character.
glimpse(email_body)
Rows: 182
Columns: 1
$ value "Hi Natsumi,\nThank you for raising a request to CDS. Please note, this ticket is n…
Thanks
Exception in thread "main" com.fasterxml.jackson.core.JsonParseException: Unexpected character (' ' (code 160)): was expecting double-quote to start field name
at [Source: (String)"{
"CorrelationId": "{{$guid}}",
"UserId": 50,
"SenderId": "ICICIL",
"MSISDN": "9845628794",
"Message": "test message",
"MTag": "12345",
"MsgType": 1,
"Costcenter" : "B99-50330"
}"; line: 2, column: 2]
Below is the code snippet for which I am getting an error.
* def json = {"test" : { "data.a":'value',"data.b":'value2' }}
* print json.test["data.a"] // This line is working getting value 'value'
* set json.tes["data.a"] = 'hello' // This line is failing with error "String index out of range: -1
Response:
[java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1967)
at com.intuit.karate.JsonUtils.setValueByPath(JsonUtils.java:257)
at com.intuit.karate.Script.setValueByPath(Script.java:1519)
at com.intuit.karate.Script.setValueByPath(Script.java:1489)
at com.intuit.karate.Script.setValueByPath(Script.java:1479)
at com.intuit.karate.StepDefs.setNamedByPath(StepDefs.java:572)
at com.intuit.karate.StepDefs.setByPath(StepDefs.java:562)
at ✽.* set json.tes["data.a"] = 'hello' // This line is failing with error "String index out of range: -1
Not able to set value for "data.a" dynamically using SET keyword.
Please help.
This seems to be very badly designed JSON. Make a small change, use eval:
* eval json.test["data.a"] = 'hello'
I'm new in Mulesoft, I'm following Quickstart guide. In Step 2 (https://developer.mulesoft.com/guides/quick-start/developing-your-first-mule-application), I need to receive variables from URI in this way:
[{'id' : attributes.uriParams.productId}]
But when I try my GET I have the following error in console:
**Message : "Cannot coerce Array ([{id: "2" as String {class: "java.lang.String"}}]) to Object 1| [{'id' : attributes.uriParams.productId}] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Trace: at main (line: 1, column: 1)" evaluating expression: "[{'id' : attributes.uriParams.productId}]". Error type : MULE:EXPRESSION Element : get:\products(productId):test_daniel-config/processors/1 # test6_db_connection:test_daniel.xml:133 (Select) Element XML : SELECT product.,CONCAT('["', (GROUP_CONCAT(variant.picture SEPARATOR '","')),'"]') AS pictures,CONCAT('[', GROUP_CONCAT('{"',variant.identifierType, '":"', variant.identifier, '"}'),']') AS identifiersFROM product INNER JOIN variant ON product.uuid = variant.productUUIDWHERE product.uuid = :id; #[[{'id' : attributes.uriParams.productId}]] *
Any Ideas? Thanks!
cannot coerce Array to object error pop's up when you are using an array where you were supposed to use an object.
in the exception above the uri-param should be treated as ab object i.e. enclosed in {} but its being treated as an array of objects [{}].
this is causing the error.
<?php
include('connect.php');
$date = $_POST['date'];
$student_ID = $_POST['student_ID'];
$full_name = $_POST['full_name'];
$year_section = $_POST['year_section'];
$payment_description = $_POST['payment_description'];
$amount = $_POST['amount'];
$received_by = $_POST['received_by'];
// query
$sql = "INSERT INTO transaction (date,student_ID,full_name,year_section,payment_description,amount,received_by) VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
$q = $db->prepare($sql);
$q>execute(array(':sas'=>$date,':asas'=>$student_ID,':asafs'=>$full_name,':offff'=>$year_section,':statttt'=>$payment_description,':dot'=>$amount,':rd'=>$received_by));
header("location: index.php");
?>
I get the following error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: number of bound variables
does not match number of tokens' in
C:\xampp\htdocs\recordmanagement\main\reg.php:15 Stack trace: #0
C:\xampp\htdocs\recordmanagement\main\reg.php(15):
PDOStatement->execute(Array) #1 {main} thrown in
C:\xampp\htdocs\recordmanagement\main\reg.php on line 15
In the code I am also unsure about the meaning of these values:
(:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft);
I downloaded it from sourcecode, so it was not written by me.
There seems to be a field to much in the query. This:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd,:ft)";
should probably be:
$sql = "INSERT INTO transaction
(date,student_ID,full_name,year_section,payment_description,amount,received_by)
VALUES (:sas,:asas,:asafs,:offff,:statttt,:dot,:rd)";
as there is no matching value for the :ft field.
Whether this is because your missing an item in the values or if it's not needed I can't say.