/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
use dataverse events;

declare type UserType as open {
  name: string,
  email: string,
  interests: {{string}},
  address: AddressType,
  member_of: {{
    {
      sig_name: string,
      chapter_name: string,
      member_since: date
    }
  }}
}

declare type AddressType as closed {
  street: string,
  city: string,
  zip: string,
  latlong: point
}

declare nodegroup group1 on nc1, nc2;

declare dataset User(UserType) primary key name on group1;

write output to nc1:"/tmp/q1.adm";

for $user in dataset('User')
where some $i in $user.interests
  satisfies $i = "movies"
return {"name": $user.name}
