I've a problem that I'm hoping someone can explain it to me.
Let's assume my data looks like this:
('1', ['1', '1', '-1']),
('1', ['1', '2', '-2']),
('1', ['1', '3', '-3']),
('1', ['1', '4', '-4']),
('1', ['1', '5', '-5']),
('1', ['1', '6', '-6']),
('2', ['2', '7', '-7']),
('2', ['2', '8', '-8']),
('2', ['2', '9', '-9'])
and I store it in an RDD with two partitions. One partition contains data for key = '1' and the other contains data for key = '2'. Now, when I run:
def do_something(partition):
print('hello')
for element in partition:
if element[0] != '1':
yield element
my_rdd_new = my_rdd.mapPartitions(do_something)
It doesn't print 'hello' but my_rdd_new contains the right subset of data, i.e.:
('2', ['2', '7', '-7']),
('2', ['2', '8', '-8']),
('2', ['2', '9', '-9'])
Can anyone explain why this is happening?!
If it helps, I'm using spark 2.0.1 and running the code in Jupyter IPython notebook.
Update: It seems Jupyter IPython is the problem. I ran it in the command prompt and it works. Now, the question is: Why does it happen and how it can be fixed?!
Thanks
Related
I have a problem with an application I want to code with Dash. I have two different checklists (indicator A, indicator B). My goal is that the user can choose multiple options for only one indicator. So it is allowed to choose a,b,c and 1. It should also be possible to select c and 2,3 at the same time. The selection of a,c and 1,2 on the other hand, should be prevented. My approach to this is the following code:
app.layout = html.Div([
html.Label('indicator A'),
dcc.Checklist(
id = 'i_a',
options=[
{'label': 'a', 'value': 'a'},
{'label': 'b', 'value': 'b'},
{'label': 'c', 'value': 'c'}
],
value = ['a']
),
html.Label('indicator B'),
dcc.Checklist(
id='i_b',
options=[
{'label': '1', 'value': '1'},
{'label': '2', 'value': '2'},
{'label': '3', 'value': '3'}
],
value=['1']
),
])
#app.callback(
Output('i_b', 'value'),
Input('i_a', 'value')
)
def change_b(value_a):
return ['1']
#app.callback(
Output('i_a', 'value'),
Input('i_b', 'value')
)
def change_b(value_b):
return ['a']
This creates an endless loop because the callbacks trigger each other. However, I have no idea how to solve the problem. I am grateful for any help :)
I think what you need is the new circular callbacks ability. Check out the examples on this page, which I think are very similar to what you're doing.
One or more input exceptions have occurred.
"postcode" is required. Enter and try again.
"countryId" is required. Enter and try again.
I'm filling these values in my account edit address page, but facing this issue.
https://prnt.sc/u95nez
During migration, there is a problem with the loss postcode and telephone attributes values from customer_form_attribute and eav_form_element tables.
Adding missing values might help:
INSERT INTO customer_form_attribute (form_code, attribute_id)
VALUES ('adminhtml_customer_address', '33'),
('customer_address_edit', '33'),
('customer_register_address', '33'),
('adminhtml_customer_address', '34'),
('customer_address_edit', '34'),
('customer_register_address', '34');
INSERT INTO eav_form_element (element_id, type_id, fieldset_id, attribute_id, sort_order)
VALUES (NULL, '1', NULL, '33', '7'),
(NULL, '2', NULL, '33', '7'),
(NULL, '3', NULL, '33', '6'),
(NULL, '4', NULL, '33', '6'),
(NULL, '1', NULL, '34', '9'),
(NULL, '2', NULL, '34', '9'),
(NULL, '3', NULL, '34', '8'),
(NULL, '4', NULL, '34', '8');
Here is a pretty streightforward code for displaying matrix in scaled color using imagesc command. The problem is that final figure has wrong labeling and doesnt show 2nd half of labels(it should be from 1 to 21, but it is from 1 to 10)
figure;
imagesc(magic(21));
set(gca,'XTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})
set(gca,'YTickLabel',{'1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21'})
I am using Ubuntu 16.04 and Matlab 2016b.
You set up the label text, but not the location, thus it will automatically put label locations and then substitute their text.
To set up the locations of the labels, first do:
set(gca,'XTick',...)
Then you can write in those labels whatever you preffer:
set(gca,'XTickLabel',{'banana', 'platano', 'potato',... })
You have to assign locations for those ticks, not just add labels.
figure;
imagesc(magic(21));
ax1 = gca;
ax1.YTick = 1:21;
ax1.XTick = 1:21;
ax1.XTickLabels = {'One','Two','Three',...
ax1.YTickLabels = {'Red','Brown','Green',...
Also since Matlab 2014b Mathworks created a new graphics system. You can access your graphics as objects directly instead of using set and get everywhere.
You can test this:
imagesc(magic(21));
set(gca,'XLim',[1 21])
set(gca,'XTick',[1:1:21])
set(gca,'XTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})
set(gca,'YLim',[1 21])
set(gca,'YTick',[1:1:21])
set(gca,'YTickLabel',{'1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21'})
So I'm starting with this...
SELECT * FROM parts_finishing;
...I get this...
id, id_part, id_finish, id_metal, id_description, date,
inside_hours_k, inside_rate, outside_material
(0 rows)
...so everything looks fine so far so I do this...
INSERT INTO parts_finishing
(
id_part, id_finish, id_metal, id_description,
date, inside_hours_k, inside_rate, outside_material
) VALUES (
('1013', '6', '30', '1', NOW(), '0', '0', '22.43'),
('1013', '6', '30', '2', NOW(), '0', '0', '32.45'));
...and I get...
ERROR: INSERT has more target columns than expressions
Now I've done a few things like ensuring numbers aren't in quotes, are in quotes (would love a table guide to that in regards to integers, numeric types, etc) after I obviously counted the number of column names and values being inserted. I also tried making sure that all the commas are commas...really at a loss here. There are no other columns except for id which is the bigserial primary key.
Remove the extra () :
INSERT INTO parts_finishing
(
id_part, id_finish, id_metal, id_description,
date, inside_hours_k, inside_rate, outside_material
) VALUES
('1013', '6', '30', '1', NOW(), '0', '0', '22.43')
, ('1013', '6', '30', '2', NOW(), '0', '0', '32.45')
;
the (..., ...) in Postgres is the syntax for a tuple literal; The extra set of ( ) would create a tuple of tuples, which makes no sense.
Also: for numeric literals you don't want the quotes:
(1013, 6, 30, 1, NOW(), 0, 0, 22.43)
, ...
, assuming all these types are numerical.
I had a similar problem when using SQL string composition with psycopg2 in Python, but the problem was slightly different. I was missing a comma after one of the fields.
INSERT INTO parts_finishing
(id_part, id_finish, id_metal)
VALUES (
%(id_part)s <-------------------- missing comma
%(id_finish)s,
%(id_metal)s
);
This caused psycopg2 to yield this error:
ERROR: INSERT has more target columns than expressions.
This happened to me in a large insert, everything was ok (comma-wise), it took me a while to notice I was inserting in the wrong table of course the DB does not know your intentions.
Copy-paste is the root of all evil ... :-)
I faced the same issue as well.It will be raised, when the count of columns given and column values given is mismatched.
I have the same error on express js with PostgreSQL
I Solved it. This is my answer.
error fire at the time of inserting record.
error occurred due to invalid column name with values passing
error: INSERT has more target columns than expressions
ERROR : error: INSERT has more target columns than expressions
name: 'error',
length: 116,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '294',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'analyze.c',
line: '945',
here is my code dome
INSERT INTO student(
first_name, last_name, email, phone
)
VALUES
($1, $2, $3, $4),
values
: [ first_name,
last_name,
email,
phone ]
IN my case there was syntax error in sub query.
I know how to set the columns in a detailview to 3 columns instead of the default 2 by putting into detailviewdefs.php
(in modules/EvMgr_Pgm/metadata if creating a custom module
or in custom/modules/EvMgr_Pgm/metadata if editing an existing module)
'maxColumns' => '3',
'widths' =>
array (
0 =>
array (
'label' => '8',
'field' => '19',
),
1 =>
array (
'label' => '8',
'field' => '19',
),
2 =>
array (
'label' => '8',
'field' => '19',
),
),
However, that sets the columns for ALL the tabs/panels in a detailview
Is there a way I can have there be 3 columns in one tab/panel and 2 columns (default) in the other tabs/panels?
If you change the widths to exceed 100 it'll recalculate the widths for a panel/table that has 3 or more columns. Try this:
'maxColumns' => '3',
'widths' =>
array (
0 =>
array (
'label' => '10',
'field' => '30',
),
1 =>
array (
'label' => '10',
'field' => '30',
),
2 =>
array (
'label' => '10',
'field' => '30',
),
),
This uses the standard 2 column 10/30 width. When a panel is created with 3 columns it'll recalculate the widths since it is greater than 100. At least as of 6.5.18 it does. Most likely it does for previous versions as well.