code: func builtinExtract(args []types.Datum, ctx context.Context) (d types.Datum, err error) {
  	unit := args[0].GetString()
  	vd := args[1]
  
  	if vd.IsNull() {
  		d.SetNull()
  		return d, nil
  	}
  
  	f := types.NewFieldType(mysql.TypeDatetime)
  	f.Decimal = types.MaxFsp
  	val, err := vd.ConvertTo(ctx.GetSessionVars().StmtCtx, f)
  	if err != nil {
  		d.SetNull()
  		return d, errors.Trace(err)
  	}
  	if val.IsNull() {
  		d.SetNull()
  		return d, nil
  	}
  
  	if val.Kind() != types.KindMysqlTime {
  		d.SetNull()
  		return d, errors.Errorf("need time type, but got %T", val)
  	}
  	t := val.GetMysqlTime()
  	n, err1 := types.ExtractTimeNum(unit, t)
  	if err1 != nil {
  		d.SetNull()
  		return d, errors.Trace(err1)
  	}
  	d.SetInt64(n)
  	return d, nil
  }
docs: // See https://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html#function_extract