Showmigrations:
accounts
[X] 0001_initial
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auth
[X] 0001_initial
[X] 0002_auto_20190430_1129
blog
[X] 0001_initial
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
core
(no migrations)
curate
[X] 0001_initial
[X] 0002_item_tags
django_comments
[X] 0001_initial
podcast
[X] 0001_initial
[X] 0002_auto_20190430_1129
[X] 0003_auto_20190430_1132
sessions
[X] 0001_initial
sites
[X] 0001_initial
[X] 0002_alter_domain_unique
taggit
[X] 0001_initial
如果我运行迁移(只是看它是否显示“没有要应用的迁移”),我会得到:
Operations to perform:
Apply all migrations: accounts, admin, auth, blog, contenttypes, curate, django_comments
, podcast, sessions, sites, taggit
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be appl
ied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrat
e' to apply them.
所以我运行了makemigrations:
Migrations for 'podcast':
podcast\migrations\0004_auto_20190430_1137.py
- Alter field published_date on show
Showmigrations:
accounts
[X] 0001_initial
admin
[X] 0001_initial
[X] 0002_logentry_remove_auto_add
[X] 0003_logentry_add_action_flag_choices
auth
[X] 0001_initial
[X] 0002_auto_20190430_1129
blog
[X] 0001_initial
contenttypes
[X] 0001_initial
[X] 0002_remove_content_type_name
core
(no migrations)
curate
[X] 0001_initial
[X] 0002_item_tags
django_comments
[X] 0001_initial
podcast
[X] 0001_initial
[X] 0002_auto_20190430_1129
[X] 0003_auto_20190430_1132
[ ] 0004_auto_20190430_1137
sessions
[X] 0001_initial
sites
[X] 0001_initial
[X] 0002_alter_domain_unique
taggit
[X] 0001_initial
我再次运行迁移:
Operations to perform:
Apply all migrations: accounts, admin, auth, blog, contenttypes, curate, django_comments
, podcast, sessions, sites, taggit
Running migrations:
C:\Users\phill\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\db\models\fields\__init
__.py:1421: RuntimeWarning: DateTimeField Show.published_date received a naive datetime (2
019-04-30 11:32:39.288026) while time zone support is active.
RuntimeWarning)
C:\Users\phill\Anaconda3\envs\myDjangoEnv\lib\site-packages\django\db\models\fields\__init
__.py:1421: RuntimeWarning: DateTimeField Show.published_date received a naive datetime (2
019-04-30 11:37:23.102936) while time zone support is active.
RuntimeWarning)
Applying podcast.0004_auto_20190430_1137... OK
但是,如果我再次运行迁移,则会收到相同的消息-这是一个循环。
Operations to perform:
Apply all migrations: accounts, admin, auth, blog, contenttypes, curate, django_comments
, podcast, sessions, sites, taggit
Running migrations:
No migrations to apply.
Your models have changes that are not yet reflected in a migration, and so won't be appl
ied.
Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrat
e' to apply them.
makemigrations:
Migrations for 'podcast':
podcast\migrations\0005_auto_20190430_1139.py
- Alter field published_date on show
这是模型中产生运行时错误的那一行,我提供了一个默认值,因为它是现有模型上的新属性,需要它。 Python还提示我使用此方法,也许这是错误的方法?
published_date = models.DateTimeField(_('Date published'), default=datetime.datetime.today(), null=True, blank=True, help_text=_('The date the feed was published'))
用于循环迁移的迁移代码在这里:
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('podcast', '0003_auto_20190430_1132'),
]
operations = [
migrations.AlterField(
model_name='show',
name='published_date',
field=models.DateTimeField(blank=True, default=datetime.datetime(2019, 4, 30, 11, 37, 23, 102936), help_text='The date the feed was published', null=True, verbose_name='Date published'),
),
]
答案 0 :(得分:1)
默认情况下,您需要传递JavaPairRDD<String, PortableDataStream> zipData =
sc.binaryFiles("hdfs://temp.zip");
JavaRDD<Record> newRDDRecord = zipData.flatMap(
new FlatMapFunction<Tuple2<String, PortableDataStream>, Record>(){
public Iterator<Record> call(Tuple2<String,PortableDataStream> content) throws Exception {
List<Record> records = new ArrayList<Record>();
ZipInputStream zin = new ZipInputStream(content._2.open());
ZipEntry zipEntry;
while ((zipEntry = zin.getNextEntry()) != null) {
count++;
if (!zipEntry.isDirectory()) {
Record sd;
String line;
InputStreamReader streamReader = new InputStreamReader(zin);
BufferedReader bufferedReader = new BufferedReader(streamReader);
line = bufferedReader.readLine();
String[] records= new CSVParser().parseLineMulti(line);
sd = new Record(TimeBuilder.convertStringToTimestamp(records[0]),
getDefaultValue(records[1]),
getDefaultValue(records[22]));
records.add(sd);
}
}
return records.iterator();
}
});
的可调用对象,而不是调用它的结果。由于结果每次都会更改,因此Django会认为您已更改了默认值。
datetime.date.today